We are about to add some quat math to the ofxVectorMath addon. It’s not there yet but for now you can use the code here: http://aaron-meyers.com/osg-ofx.zip
Basically what you have to do is convert your start rotation and end rotation to quat representation. These two quats you then use in the slerp function along with an interpolation percentage. The quats you create with the makeRotate methods in this preliminary code.
wow, looks great!
ive been putting my own quaternion class together from bits of resources of the web… will run with yours from now on.
for now, a quick question…
is there an easier way of passing the ofxMatrix4x4 transformation into opengl.
currently im doing this, seems a little redudant to copy the matrix values from a 2D to 1D array.
ya, you can just pass in a pointer to “mat”. This means if mat is on the stack like in your example you need to write it like “&mat”. Make sure though that you use glMultMatrixf if you are using floats. Also, there is a column order that might match opengl or not. I haven’t verified this yet with the code I sent you. It’s a bit tricky because the terminology is very ambiguous and column-major or row-major alone is still not clearly defined because different programming languages store 2D arrays in different ways.
cool, so i’ve been using ofxQuat for slerp interpolation - working out the shortest path along the surface of a sphere and im so close i can taste it!
heres where im up to,
i have two points between which im slerping, so to speak. these are a latitude and longitude pairs.
i convert the latitude and longitude pairs into cartesian coordinates (XYZ) on the unit sphere.
i represent the points as flat planes and rotate them so the out vector points to the center of the sphere, the right vector along the longitude (across) of the sphere and the up vector towards the poles.
having this information i have enough to create a transformation matrix for each of the points btween which im interpolating.
i then pass the two matrices for the two points into two quaternions and slerp between them
for each step of the slerp i get a quaternion → get the matrix out of the quaternion and use the out vector of the matrix as the next point on the geodesic path.
issue now is, because the planes are oriented to always point up to the poles and point right along the longitude, the geodesic slightly curves… so it doesn’t give me a the shortest path… the attached example can demonstrate.
think the last thing left to do which will solve this problem is to make sure that the planes are aligned so they point up along the tangent of the great cirlce on which they are on.
i think…
please let me know if you know better.
or have any suggestions.