Jump to content
  • Advertisement
Sign in to follow this  
Sneftel

Generalized axis alignment metric

This topic is 3902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Given a 3x3 rotation matrix M, is there any clean, robust, simple way to come up with a scalar describing how axis-skewed it is? That is, I'd like it to return 0 for a 90 degree rotation about the X axis, because each of the axes lines up with a unit axis (even though they don't correspond), and greater than 0 for a 45 degree rotation around the X axis, because they don't all line up. I don't much care about the particular function curve as long as it's reasonably well-behaved.

Share this post


Link to post
Share on other sites
Advertisement
Maybe 3 minus the absolute values of the dot products of each of the axis pairs, for the pairs of axes that maximize that sum. Hmm...I think this would be the same as finding the maximum of the absolute values for each row in the rotation matrix, and then subtracting their sum from 3.

For the 45 degree rotation on one axis, this produces a value of 2-sqrt(2), or about .59.

I think for the most unaligned case, the value is 3-sqrt(3), about 1.27.

Share this post


Link to post
Share on other sites
Dot products of each of the axis pairs would be zero; the matrix is orthonormal, after all. I settled on something similar, simply summing the absolute values of the nine entries and subtracting 3. I'm not sure Euler would approve, but it certainly seems to work okay.

Share this post


Link to post
Share on other sites
I mean pairing together the axes of the rotation matrices being compared, one of which is just the global axes, so it would be the identity matrix.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Dot products of each of the axis pairs would be zero; the matrix is orthonormal, after all.
I think Vorpy meant to take the dot products of the matrix that is being tested and the axes of each of the 12 (is that right?) axis-aligned rotation matrices. For each of the 12, compute the three dot products (x1.x2, y1.y2, z1.z2) and subtract their sum from three. The minimum of the resulting values would then be a measure of the matrix' alignment.

That's just how I interpreted the post though (I could be wrong).

Share this post


Link to post
Share on other sites
Out of curiousity I tried running some tests on these two functions. I made a mistake in the first post when talking about the highest value my function could give; I forgot that it is impossible for all 3 axes of the rotation matrix to each be equidistant from each of the global axes.

I ran the functions on random matrices looking for maximums, and the functions appear to agree that the rotations/reflections furthest from the axes look like:

[ 1/3, 2/3, 2/3]
[ 2/3, 1/3, -2/3]
[-2/3, 2/3, -1/3]

with my function evaluating to 1 and Sneftel's evaluating to 2. What I'm less sure about is the area in between, where I think there is some disagreement between the functions as to whether some matrices are more skewed from the axes than others. For example, the matrices:

[0.94141562904493614, -0.33555553308610503, 0.033750520073435722],
[-0.33720552133383791, -0.9349705136596359, 0.11010256567860349],
[-0.0053897840310916378, -0.11503313784443496, -0.99334703272610714]

and

[0.18841985587809659, -0.96831904625777387, 0.16387856041994123]
[-0.20681452976682993, 0.12400308849701262, 0.97049007430294054],
[-0.96006547078217652, -0.21675206734339847, -0.17689780415302075]

Sneftel's function gives the second a higher value, my function gives the first a higher value. In fact, Sneftel's gives the second a higher value than a matrix rotated 45 degrees along one axis, while mine does not. I'm not sure what to make of these intermediate matrices, really.

I imagine the functions could be graphed as elevations on a 4 dimensional sphere, but then how does one visualize that? I conjecture that it would look pretty cool.

Share this post


Link to post
Share on other sites
Another option that springs to mind is to compute the (positive) angles of rotation (over the shortest arc) that would bring the matrix into alignment with each of the 12 axis-aligned orientations, and then take the minimum of the resulting values.

This seems less elegant than the ideas proposed thus far (and would certainly be more costly to compute). But it also seems the resulting function would have different characteristics than the functions proposed so far, so I thought it might be worth mentioning.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!