MAXScript FAQ > Working With Editable Meshes > How do I Get the Local Rotation of a Face? |
Here is how to obtain the rotation value displayed in the Rotate Transform Type-In box when in the local coordinate system from a face in an Editable Mesh.
GetFaceNormal returns the face normal in local coordinates as a Point3 value.
Multiplied by the transformation matrix of the object, we get the face normal in world space.
Using matrixFromNormal, we create a new matrix3 value using the face normal as the local Z axis. This matrix3 value is rotated relatively to the identity matrix exactly by the values we are searching for.
By converting the matrix3 value toeulerAngles, we retrieve exactly the same 3 values displayed in the Transform Type-In when a face is selected while in Local coordinate system.