-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry_test.py
81 lines (62 loc) · 2.42 KB
/
geometry_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import matplotlib.pyplot as plt
from transforms import *
# coord = Translation2d(1 , 1)
# plt.scatter(coord.getX(), coord.getY())
# coord = coord.rotateBy(Rotation2d.fromDegrees(90))
# plt.scatter(coord.getX(), coord.getY())
# plt.scatter(0, 0)
# print(coord)
current = RigidTransform2d(Translation2d(0,0), Rotation2d.fromDegrees(0))
left = 5
right = 5.5
rads = 30.0 * math.pi / 180.0
plt.scatter(current.getTranslation().getX(), current.getTranslation().getY())
print(current)
delta = RigidTransform2d.Delta((left + right)/2, 0, rads)
current = current.transformBy(RigidTransform2d.fromVelocity(delta))
print(current)
print(current.getTranslation().norm())
plt.scatter(current.getTranslation().getX(), current.getTranslation().getY())
current = RigidTransform2d(Translation2d(0,0), Rotation2d.fromDegrees(0))
left = 5
right = 5
rads = 60.0 * math.pi / 180.0
delta = RigidTransform2d.Delta((left + right)/2, 0, rads)
current = current.transformBy(RigidTransform2d.fromVelocity(delta))
print(current)
print(current.getTranslation().norm())
plt.scatter(current.getTranslation().getX(), current.getTranslation().getY())
current = RigidTransform2d(Translation2d(0,0), Rotation2d.fromDegrees(0))
left = 5
right = 5
rads = 90.0 * math.pi / 180.0
delta = RigidTransform2d.Delta((left + right)/2, 0, rads)
current = current.transformBy(RigidTransform2d.fromVelocity(delta))
print(current)
print(current.getTranslation().norm())
plt.scatter(current.getTranslation().getX(), current.getTranslation().getY())
current = RigidTransform2d(Translation2d(0,0), Rotation2d.fromDegrees(0))
left = 5
right = 5
rads = 0.0 * math.pi / 180.0
delta = RigidTransform2d.Delta((left + right)/2, 0, rads)
current = current.transformBy(RigidTransform2d.fromVelocity(delta))
print(current)
print(current.getTranslation().norm())
plt.scatter(current.getTranslation().getX(), current.getTranslation().getY())
#plt.show()
curr = Rotation2d.fromDegrees(45)
start = Rotation2d.fromDegrees(-45)
offset = start.inverse().rotateBy(curr)
print(offset)
curr = RigidTransform2d(Translation2d(-480, 120), Rotation2d(1, 1, True))
delta = RigidTransform2d(Translation2d(-20, 0), Rotation2d(1,0, False))
print(curr)
print(delta)
result = curr.transformBy(delta)
print(result)
start = RigidTransform2d(Translation2d(120, 480), Rotation2d(0, 1, False)).getTranslation()
max_loc = Translation2d(50, 0).rotateBy(Rotation2d(-1, 0, False))
print(max_loc)
end = start.translateBy(max_loc)
print(end)