when I draw this scene I get what I want: the sphere drawn and the center of the texture is aligned with the camera.
However, I don’t understand why. I understand how quaternions work to change an orientation, but not how they define an absolute orientation. The values that I used were based on trial and error.
wait, it’s (angle,axis)? I got confused and thought it was (axis,angle).
When you use .setOrientation which is the reference orientation?
One last question,
ofQuaternion(90,0,1,0);
is not equivalent to
ofQuaternion(90, ofVec3f(0,1,0)); ?
Hey there, no it is of course not! A quat is essentially a 4D vector, normalized to 1 (!), which encodes a rotation in 3D space. You can convert from an axis-and-angle or rotation matrix representation to a quaternion and vice versa. Without having looked at the actual API, I pretty much suppose the former form initialises a quat with those 4 values, whereas the latter does a conversion from AAA to quat representation. The values you supply in the first form don’t even make for a well-defined quat/rotation since it is not normalized! I hope that makes things clear, otherwise ask, I’ve dealt with those 3D transform math quite a lot in the past.
Where a is the angle of rotation, and [nx, ny, nz] a normaized axis.
The most advantageous properties of quats are
They avoid the “gimbal lock” problem of Euler angles which is essentially a singularity in the transform math, creates numerical instabilities and needs to be accounted for in an implementation.
They can be interpolated nicely using the “slerp” spherical linear interpolation, which kinda interpolates between the two quats on a 4D unit sphere, making things like keypoint based animation rather straightforward.
Don’t worry about that, you’ll lose the new member status soon enough, that’s just to avoid spam.
Yeah, I found that out later researching; I had just assumed the quaternion behaved as a 3dvec + an angle. I was confused because the ofQuaternion class in oF can be created in such a way, but requires you to explicitly pass the ofVec3f as a second argument.
Thanks for the links, I’ll read those!