# getRotationColumn... How does it work !?

Hi guys,

I am trying to get my head around getting a Nodes direction. I can get it to a Quaternion and call this “getRotationColumn(x)” on it, but I am confused (as usual) as to what 0, 1 and 2 are about. I’ve hunted around now on the JME forums and searched the JME documentation. As yet no success. Which one should I use… And why!?

Hope you can help. My apologies if this is documented somewhere. I’ve even tried Google to see if this is standard vector terminology. Nothing yet!

Thanks

Richard

What do you mean by a nodes “direction” ?

getRotation will tell you how it’s oriented. Models don’t innately have a “forwards” direction though. You would need to define one from the original model and then multiple that by getWorldRotation to find the current direction the model is facing.

Yes, good point, so let me clarify my thinking.

What I hope I am doing right is converting the nodes world rotation, and from that, using “getRotationColumn(x)” to get my “direction”. From that Vector, I can then use “mult(f)” to move it along that path a given distance (f).

Am I off the mark here?

Vector3f dir = spatial.getRotation().mult( new Vector3f(0,0,1) );

…or something like that.

Maybe this helps:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

Or this:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

Thanks pspeed but I’ve been through these before, and there’s no mention of a rotation column and what is actually is.

But I think I have worked it out via a rudimentary test. I could maybe wiki this, but the rotation colummn is effectively which angle to traverse along, x, y, or z. At least, that’s what I can see from my test. I have some working theories about the values it returns, and I am trying a few tests to see if they tally up with my theory.

Thanks again all.

• Richard

I think the idea behind @pspeeds post was more to not use rotation columns when what you are interested in is the direction of the spatial. It will only give you headaches with gimbal lock and euler angles.

Got it. Thank you. So pspeeds statement:

[java] Vector3f direction = spatial.getLocalRotation().mult(Vector3f.UNIT_Z);[/java]

Is the same as:

[java]Vector3f direction = spatial.getLocalRotation().getRotationColumn(2);[/java]

I can see that the first statement makes a bit more sense, but other than that I guess there’s no difference.

My brain was never cut out for this!

But thank you all again.

@richard_hawkes said:
Got it. Thank you. So pspeeds statement:
[java] Vector3f direction = spatial.getLocalRotation().mult(Vector3f.UNIT_Z);[/java]
Is the same as:
[java]Vector3f direction = spatial.getLocalRotation().getRotationColumn(2);[/java]
I can see that the first statement makes a bit more sense, but other than that I guess there's no difference.

My brain was never cut out for this!

But thank you all again.

The second one is doing weird tricky non-understandable-by-laymen voodoo. The first one is doing "exactly what you are trying to do", ie: figure out what the default look direction is according to the spatial's rotation.

The second one also might be doing more work but I haven't looked at the code. Normally I think of "rotation columns" as part of a rotation matrix. A rotation matrix can be thought of as the three orthogonal axes of a rotated space... in which case 0 will be the x-axis, 1 will be the y-axis, and 2 will be the z-axis. In JME the z-axis happens to also be the default direction.

But JME keeps rotations as the Quaternions because they are way more efficient... I don't know how much work it does to pull the columns of a rotation matrix out of a Quaternion... but anyway... you might as well write code that is doing what you intend, ie: rotate a default direction vector as in my example.
@pspeed said:
The second one is doing weird tricky non-understandable-by-laymen voodoo.

Thanks psped. As far as I'm concerned, Quaternion is another word for voodoo.