safely interpolate rotations

Started by raft, January 04, 2010, 11:45:39 PM

Previous topic - Next topic

raft

hi,

Ardor uses quaternions for rotations. in demo, it calculates a rotation from a vector to a vector and interpolates rotation with identity rotation. AFAIK with quaternions this is perfectly legal and make sense.

i tried to emulate this in jPCT by interpolating two matrices. sometimes results become very strange. i guess this happens when two rotations (matrices) are too different. afterall interpolating matrices for rotations does not makes sense mathematically.

so is there a safe way in jPCT to interpolate a rotation ?

r a f t

EgonOlsen

No, there isn't. You are right that the matrix interpolation fails, if the input matrices are too different. Imagine one matrix that rotates a vertex to 0,0,1 and another that rotates it to 0,0,-1. It's impossible to interpolate between these matrices by using a linear interpolation of the matrices' values and create proper inbetween states that way. jPCT ensures that the interpolated matrix is a valid rotation matrix, but it doesn't make any assurances if it really fits the purpose.
You have to use your own quaternion implementation for this. Cyberkilla's old Skeletal-API from the download page should have one IIRC. Maybe that helps.

EgonOlsen

I've had a quick look at his API. It has a Quaternion class and a method in the Matrix class to create a Matrix from a quaternion. Looks promising IMHO...except that it doesn't say anything about row-/column-majority... ;)

raft

ok, i'll have a look at that.

you sometimes say that, one can do anything with matrices that can be done with quaternions. seems as it's not the case actually ;)

EgonOlsen

No, that's still true. Both concepts are mathematically equivalent. When both concepts were invented, they struggled for which is best....and matrices won. But that doesn't mean that everything is as easy in one concept as it is in the other. Or in other words: I've no idea how to do this interpolation with matrices, but it is possible somehow.
Anyway, go with quats for this. It should be much easier. And i assume that CK's Matrix class is column-major, because he used jPCT's set- and getDump()-method to convert between the two IIRC...and that method actually does an implicit conversion.

raft

ok, i will make a quaternion which can interoperate with jPCT matrices. and maybe you can add it or your own to jPCT core for such purposes.

raft

i really think a simple quaternion is needed in jPCT core. what do you think ?

Bones has a Quaternion which is a stripped and modified version of Ardor's. modified to fit jPCT matrices. i'm not sure it's bug free but i've extensively tested (with random values) converting to/from jPCT matrices

EgonOlsen

If i'm allowed to take that part and add it, i will happily do so.

raft

it sounds ok with the "Do whatever with it" license ;)

MrCoder

    1. The origin of this software must not be misrepresented; you must not
    claim that you wrote the original software. If you use this software
    in a product, an acknowledgment in the product documentation would be
    appreciated but is not required.

    2. Altered source versions must be plainly marked as such, and must not be
    misrepresented as being the original software.


    3. This notice may not be removed or altered from any source
    distribution.

http://ardorlabs.trac.cvsdude.com/Ardor3Dv1/browser/trunk/LICENSE

feel free to add some ardor3d notes/mentionings on the jpct site ;)

EgonOlsen

Is it ok to add these to a closed source distribution like jPCT then? I can't find any information in the license that deals with that. It speaks of "source versions" and "source distributions", but jPCT isn't. On the other hand, it allows one to distribute modified, even commercial, versions without mentioning the product (Ardor3D).

So according to the license, i'm allowed to modify the sources and distribute a product based on that freely and i don't have to mention Ardor3D (albeit appreciated, of course)...but do i have to distribute the sources!? The license doesn't seem to cover this.

Don't get this wrong. It's not my intention to claim that i did this class or something like that, if i should decide to add it...i just want to get this right.

MrCoder

With the current license I think it's fine for you to add modified sources to your stuff (i guess it says you should add notes in your source that it is, but since it's closed source who can check :) )

Just wanted to clarify that it's not really a "Do whatever with it", even if it's close ;)