Encoding of rotation in Transformation matrices

Encoding of rotation in Transformation matrices

Anonymous
Not applicable
673 Views
0 Replies
Message 1 of 1

Encoding of rotation in Transformation matrices

Anonymous
Not applicable

I'm trying to decompose combos of translation and rotation matrices back into the translation vector and rotation and I found this strange thing. Can anyone can shed some light on this?

 

The rotation angle should be encoded in the matrix  like this:

rotation matrix.JPG

 

and therefor the rotation angle can be calculated with this formula:

 

Transform transform = Transform.CreateRotation(XYZ.Z, Math.PI/4);
dobule rotation = Math.Atan2(transform.BasisY.X, transform.BasisX.X);

The weird thing is that while positive angles rotate geometry counter-clockwise in Revit, the matrix basis vectors encode it like it would be negative and therefor return a negative angle from the formula

 

For example the matrix that Transform generates for a 45 degrees rotation is

(0.707106781, 0.7071067810.000000000)
(-0.7071067810.7071067810.000000000)
(0.0000000000.0000000001.000000000)

 

BasisY.X should be sin(45) -> 0.707106781, but it is -0.707106781 -> sin(-45)

 

I know it is easy to correct it by changeing the sing of the value returned from Atan2, but why does it behave like this?

 

Thanks,

Taavi

 

 

0 Likes
674 Views
0 Replies
Replies (0)