Decompose Transformation to axis and single angle

Hi All

Does anyone know a way to decompose a Transformation to an axis (a point and vector) and an angle? What I need is the opposite of Transformation.rotation, not X rotation, Y rotation and Z rotation (which I know have been covered before in the forum). I think the rotation axis I’m looking for is called an eigenvector but I don’t know how to find it. This math is way beyond what I’ve ever studied in school.

Speaking non-mathematically, that doesn’t sound like enough information to specify a unique transformation. What is the plane of the angle?

Or is it ‘around’ the vector? If so, that would enough, intuition tells me. But it wouldn’t account for any scaling, unless the length of the vector relative to a unit vector were used to give uniform scale. Wouldn’t account for non-uniform scale though.

Can you show diagrammatically, what you are trying to achieve?

PS. Have you read the Wikipedia article about eigenvalues and eigenvectors?
[Edit: broken link corrected]

Does it help?

Not sure which page @john_mcclenahan’s link goes to, as for some reason I can’t follow it, but the following (which might be the same) addresses what I think you are asking:

Edit: You get the matrix from the upper 3x3 of SketchUp’s 4x4 representation. If it is not actually a pure rotation, the calculations given may blow up!

There is also quaternions. Programs like Unity use those, I think because you’re more certain to get what you intended.

Thanks all!

I’ve read up a bit on Quaternions and other methods but it seems quite complicated. I was hoping there was already a finished library or something out there but I can’t find any and implementing it all from scratch is just too much work for this project. I think I’ll find another way around this.

I agree with Colin, you need to use a matrix to quaternion function, then convert the quaternion back to axis and angle.
Quaternions are essentially axis-angle representations, so the last step should be fairly simple.

This site may be of assistance:

1 Like

I have used axis angle for animations. I created a Ruby version, developing from Wikipedia’s Axis-Angle article, as well as:

The Brannon PDF includes Fortran source code.

The angle isn’t that hard to obtain. The rotation axis is difficult at angles near zero and pi.
I have attached a version in Ruby.
bhy_euler_axisangle.rb (15.4 KB)

I had to heavily edit it to remove my other utilities, and it was only tested for one angle/axis.
Someone with the background (@Aerilius ?) should give it a through peer review, not to mention unit testing.

I have moved on to using the Eigen library version of axis-angle in a Ruby C extension, and it is a bit faster. If I use the method (“Bhy::Utilities.get_AxisAngle”), it is always called outside an animation loop.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.