rotation on an axis
rotation on an axis
is there a helper fucntion that accepts a 3d vector tp perfrom rotation on an axis?
In that case quaternions are the answer. I am not an expert in its use, but you may get some ideas from this example:
If you search the forum or google for the terms I mentioned in my previous post you will find lots of useful links to sites explaining the use of quaternions like:
http://www.euclideanspace.com/maths/alg ... /index.htm
http://www.isner.com/Transform/IsnerTra ... nip_04.htm
Maybe some wise person has time to write a tutorial on the subject of rotations and quaternions as it leads to questions often
Code: Select all
const irr::f64 GRAD_PI = 180.0 / 3.1415926535897932384626433832795;
core::vector3df Target;
core::quaternion QuatStart(0,0,0,1); // Initial rotation, set to 0 in example
core::vector3df Rotation(1.0f, 0.0f, 0.0f); // Your rotation vector
irr::f64 Degrees = 90.0f / GRAD_PI; // 90 degrees around vector
core::quaternion QuatRotation(Rotation.X,Rotation.Y,Rotation.Z,Degrees);
QuatStart.toEuler(Target);
Target *= GRAD_PI;
printf("Before xyz=%2.4f,%2.4f,%2.4f\n", Target.X, Target.Y, Target.Z);
QuatStart *= QuatRotation; // calculate rotation
QuatStart.toEuler(Target); // store in new vector as Euler rotation // for use with irrlight setRotation function
Target *= GRAD_PI; // convert back to degrees
printf("After xyz=%2.4f,%2.4f,%2.4f\n", Target.X, Target.Y, Target.Z);http://www.euclideanspace.com/maths/alg ... /index.htm
http://www.isner.com/Transform/IsnerTra ... nip_04.htm
Maybe some wise person has time to write a tutorial on the subject of rotations and quaternions as it leads to questions often
-
Raymond
but how to rotate a node about an axis
I got similar problem and what I want is to rotate about a vertical axis instead of its own y axis of the node. How can I do that ?
Hi Raymond,
Not sure if this is what you want, but these quaternions give you a rotation about the x, y or z axis.
and then multiply like this:
Still nobody inclined to write a tutorial about quaternions

Not sure if this is what you want, but these quaternions give you a rotation about the x, y or z axis.
Code: Select all
core::quaternion QuatX(sin(degrees / 2),0 ,0 ,cos(degrees / 2));
QuatX.normalize();
core::quaternion QuatY(0 ,sin(degrees / 2),0 ,cos(degrees / 2));
QuatY.normalize();
core::quaternion QuatZ(0 ,0 ,sin(degrees / 2),cos(degrees / 2));
QuatZ.normalize();and then multiply like this:
Code: Select all
QuatStart *= QuatY; // for example around Y xisStill nobody inclined to write a tutorial about quaternions