Grasshopper

algorithmic modeling for Rhino

X,Y,Z rotations of a plane in degrees relative to CPlane (Python)

Is there any way to get a list of 3 values (xRotation, yRotation, zRotation) representing the rotations of a plane around the x, y and z axis (Euler angles) in Python?

Views: 1639

Replies to This Discussion

I figured it out:

you can find the transformation matrix by using:

rotMatrix = rs.XformChangeBasis (targetPlane, basePlane)

It is then possible to find the rotations using the equations below which are adapted from a c# component written by Daniel Piker (http://www.grasshopper3d.com/forum/topics/plane-rotations-x-y-z-a-b...) :

xRotation = math.degrees(math.atan2(rotMatrix[2,1], rotMatrix[2,2]));

yRotation = math.degrees(-math.atan2(rotMatrix[2,0], math.sqrt(rotMatrix[2,1] * rotMatrix[2,1] + rotMatrix[2,2] * rotMatrix[2,2])));
zRotation = math.degrees(math.atan2(rotMatrix[1,0], rotMatrix[0,0]));

print xRotation 
print yRotation 
print zRotation


I have attached a file with the definition

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service