AnsweredAssumed Answered

How do I convert from a rotation matrix to Heading, Pitch, and Roll?

Question asked by oneleggedredcow on Sep 17, 2015
Latest reply on Sep 30, 2015 by oneleggedredcow

Starting with a 3D rotation matrix, how do I compute the Heading, Pitch, and Roll values that the various 3D symbols desire?

 

More Detail:

 

So, given a rotation matrix that looks like this:

 

[ M00, M01, M02 ]

[ M10, M11, M12 ]

[ M20, M21, M22 ]

 

And I'm trying to create a ConeMarkerSymbol.

 

First I tried this computation (source):

 

Heading = Math.Atan2(M10, M00) * (180 / Math.PI)

Pitch = Math.Atan2(-M20, Math.Sqrt(M21 * M21 + M22 * M22)) * (180 / Math.PI)

Roll = Math.Atan2(M21, M22) * (180 / Math.PI)

 

But that didn't yield the correct results.  Then I tried this computation (source):

 

Heading = Math.Atan2(M20, M21) * (180 / Math.PI)

Pitch = Math.Acos(M22) * (180 / Math.PI)

Roll = -Math.Atan2(M02, M12) * (180 / Math.PI)

 

But that didn't get it either.  What's the correct calculation?

 

Even More Details:

 

I'm doing all of my business logic using a state planar projection and then converting it to WGS84 to display it in a SceneView.  The GraphicsLayer is using a SurfacePlacement of Absolute and I'm able to place all of the objects correctly, but getting them oriented properly is a challenge.  I am able to render the objects in an DirectX window with the correct orientation, so I think the rotation matrix is correct,

 

I'm using C# and the .NET runtime SDK.  Thanks in advance!

Outcomes