-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform.py
43 lines (32 loc) · 854 Bytes
/
transform.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
import roboticstoolbox as rtb
import numpy as np
import matplotlib.pyplot as plt
from spatialmath import *
from spatialmath.base import *
# from sympy import Symbol, Matrix
theta_deg = 30
theta_rad = np.deg2rad(theta_deg)
# R = rot2(theta_rad)
# print(R)
# R2=trot2(theta_rad)
# trplot2(R)
T0 = transl2(0,0) #Referencia
trplot2(T0, frame="0", color="k")
#Traslación de 1,2 seguida de rotación de 30 grados
TA = transl2(1,2) @ trot2(theta_deg, "deg")
print(TA)
trplot2(TA, frame="A", color="b")
#Rotación de 30 grados seguida de traslación de 1,2
# TB = trot2(theta_deg, "deg") @ transl2(1,2)
# print(TB)
# trplot2(TB, frame="B", color="r")
P=np.array([4,3])
plot_point(P, "ko", text="P")
P1=homtrans(np.linalg.inv(TA), P)
print(P1)
plt.axis('equal')
plt.grid(True)
plt.xlabel('X')
plt.ylabel('Y')
plt.title('Transformación 2D')
plt.show()