Created
August 10, 2018 09:57
-
-
Save rfzeg/089a3126131716a97ccd4efc8976e740 to your computer and use it in GitHub Desktop.
Perform an intrinsic rotation sequence about the Y and then Z axes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import symbols, cos, sin, pi, sqrt | |
from sympy.matrices import Matrix | |
### Create symbols for joint variables | |
q1, q2 = symbols('q1:3') | |
# Create a symbolic matrix representing an intrinsic sequence of rotations | |
# about the Y and then Z axes. Let the rotation about the Y axis be described | |
# by q1 and the rotation about Z by q2. | |
# Replace R_y and R_z with the appropriate (symbolic) elementary rotation matrices | |
R_y = Matrix([[ cos(q1), 0, sin(q1)], | |
[ 0, 1, 0], | |
[-sin(q1), 0, cos(q1)]]) | |
R_z = Matrix([[ cos(q2), -sin(q2), 0], | |
[ sin(q2), cos(q2), 0], | |
[ 0, 0, 1]]) | |
# and then compute YZ_intrinsic | |
YZ_intrinsic_sym = R_y * R_z | |
# Numerically evaluate YZ_intrinsic assuming: | |
# q1 = 45 degrees and q2 = 60 degrees. | |
# NOTE: Trigonometric functions in Python assume the input is in radians! | |
print("Rotation about the Y-axis by 45-degrees and then about the Z-axis by 60-degrees") | |
YZ_intrinsic_num = YZ_intrinsic_sym.evalf(subs={q1: pi/4, q2: pi/3}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On intrinisic sequences of rotations the subsequent elementary rotations are post-multiplied