In [24]:
import sympy
from sympy import *
sympy.init_printing()
In [25]:
def Rx(t):
return Matrix([ [1, 0, 0],
[0, cos(t), -sin(t)],
[0, sin(t), cos(t)]])
def Ry(t):
return Matrix([ [cos(t), 0, sin(t)],
[0, 1, 0],
[-sin(t), 0, cos(t)]])
def Rz(t):
return Matrix([ [cos(t), -sin(t), 0],
[sin(t), cos(t), 0],
[0, 0, 1]])
In [26]:
theta1 = Symbol('theta1')
theta2 = Symbol('theta2')
theta3 = Symbol('theta3')
In [27]:
x1, y1, z1 = symbols('x1 y1 z1')
x2, y2, z2 = symbols('x2 y2 z2')
x3, y3, z3 = symbols('x3 y3 z3')
In [28]:
l1, l2 = symbols('l1 l2')
In [29]:
Rx(theta2).dot(Matrix([[0], [0], [-l1]]))
Out[29]:
In [30]:
temp = Rx(theta2).dot(Matrix([[0], [0], [-l1]]))
Ry(theta1).dot(temp)
Out[30]:
In [31]:
Rx(theta2).dot(Ry(theta1))
Out[31]:
In [32]:
p3 = Matrix([[-l2 * sin(theta3)], [0], [-l1 -l2 * cos(theta3)]])
In [33]:
Rx(theta2).dot(Ry(theta1)).dot(p3)
In [63]:
a = Ry(theta1).dot(Rx(theta2))
a = Matrix(a)
a.rows = 3
a.cols = 3
Matrix(a.dot(p3))
Out[63]:
In [35]:
Rx(theta2).dot(p3)
Out[35]:
In [36]:
Rx(theta2).dot(p3)
Out[36]:
In [37]:
x1, y1, z1 = Rx(theta2).dot(p3)
In [38]:
x1
Out[38]:
In [39]:
y1
Out[39]:
In [40]:
z1
Out[40]:
In [41]:
l1, l2, l3 = symbols('l1 l2 l3')
In [42]:
x1 = l1 * cos(theta1)
In [43]:
z1 = -l1 * sin(theta1)
In [44]:
y1 = 0
In [45]:
a = Rz(theta2).dot(p3)
b = Ry(theta1).dot(a)
b
Out[45]:
In [46]:
a = Rz(theta2).dot(Ry(theta1))
a = Matrix(a)
a.rows = 3
a.cols = 3
b = a.dot(p3)
b = Matrix(b)
b
Out[46]:
In [49]:
p1 = Matrix([[0], [0], [-l1]])
In [50]:
a = Rz(theta2).dot(Ry(theta1))
a = Matrix(a)
a.rows = 3
a.cols = 3
b = a.dot(p1)
b = Matrix(b)
b
Out[50]:
In [ ]: