Hey everyone,

I’m trying to wrap my head around using quaternions (versus understanding them) and I’m having a bit of trouble conceptualizing things. I have an arbitrary piece of geometry that already has a predefined rotation, let’s say 90 degrees on the (1, 1, 1) axis. I’m trying to rotate that totality around the generic y axis such so the vector would then be (-1, 1, 1) or something close to it…hard to visualize in 3d space. The problem is, each time I’m multiply the quaternion I’m crafting, the geometry flips on it’s side and then rotates around the y axis. Can anyone point me in the right direction? Need more information?

thanks!

jW

If you want to rotate it around the spatials current y axis

[java]//this rotates stuff for 90 dedgrees around the y axis

public static final Quaternion YAW090 = new Quaternion().fromAngleAxis(FastMath.PI/2, new Vector3f(0,1,0));

spatial.setLocalRotation(…);

…

//get the rotation, apply rotation of 90 degrees on the spatials rotated y axis

spatial.setLocalRotation(spatial.getLocalRotation().mult(YAW090));[/java]

or

if you want to rotate to -1,1,1 around the world y axis

[java]

spatial.setLocalRotation(…);

…

Quaternion rotation =spatial.getLocalRotation.clone();

spatial.setLocalRotation(rotation.lookAt(new Vector3f(-1,1,1), Vector3f.UNIT_Y));

[/java]

i dont know if that works though

Ah, I should clarify. I don’t have direct access to the Spatial, rather a scenegraph node. The only method it looks like I have access to is setLocalRotation() …

Ah sry, everywhere needs to be setLocalRotation / getLocalRotation

Just substitue spatial with node

Nehon, thank you so much for that link, it explains things very gently!

I ended up figuring it out late last night with the solution being I needed to create the quaternion from angles, and update the angles on each update().

thanks again!

jW

that’s cool you found your way out of this.

for the article, thanks Normen as he’s the actual author