Advertisement

blending an arbibtrary number of quats

Started by July 19, 2002 08:42 AM
2 comments, last by Geocyte 22 years, 7 months ago
Does anyone happen to know of a good reference which explains how to find the average of any number of quat rotations? At the moment my skeletal animation system applies vertex weighting by linearly interpolating between the vertex positions resulting from transformation by the attached bones. This seems to be a common method but, as I understand it, not mathematically correct. I realise that the improvement in visual quality will be fairly minor compared to the amount of processing required but it''s just a demo so that shouldn''t be a problem. Couldn''t find much about this on the web which I thought strange since it seems like a useful thing to know. Perhaps I was looking in the wrong places. Any hints on how to proceed would be appreciated. Geocyte Has Committed Suicide.
Geocyte Has Committed Suicide.
You can just blend them linearly, e.g. treating them as 4D vectors, using whaterve weights make sense for your data, then renormalise.

This will generally produce pretty good results for quaternions close to each other . The terms ''pretty good'' and ''close'' are subjective measures, i.e. your milage may vary, but there are a couple of things that apply in general.

First SLERP, or spherical interpolation, is the most usual way of interpolating between two quaternions, but is expensive to calculate and doesn''t generalise simply to more than two quaternions. Spherical and linear interpolation are indistinguishable for small angles, maybe less than 30 degrees(pi/6 radians). The difference between them grows quadratically or worse as angle increases, i.e. double the angle and the errors are 4x or more worse.

Second each rotation is represented by two different quaternions, q and -q, and when blending/interpolating quaternions it''s important to make sure they are represented by the quaternions of the (q, -q) pairs that are closest.

For two quaternions the usual way of doing this is do the 4D dot product of the quaternions and negate one of them if the result is negative as this indicates they point in opposite directions in 4D space.

I don''t know of a simple method for more than two quaternions: it should always be possible for a nice set of quaternions, such as ones representing rotations, but how to do it will I suspect depend on the data. Perhaps just pick one and try the above proceedure with all the others in turn.
John BlackburneProgrammer, The Pitbull Syndicate
Advertisement
quote:

You can just blend them linearly, e.g. treating them as 4D vectors, using whaterve weights make sense for your data, then renormalise.



Yeah, that would seem to be a more accurate method than my 3d lerp. The speed at which the points follow their arcs would still be incorrect (I think) but they should at least be travelling along the proper paths. I carried on looking and there doesn''t seem to be a well established method of doing this spherically. I''ll probably just use your method and come back to this another time. Thanks.

Geocyte Has Committed Suicide.
Geocyte Has Committed Suicide.
Basically, if you just linearly blend all the quaternions together, and then normalize, it will work.

For more of an explanation about this you can see my Game Developer Magazine articles from earlier this year (don''t have them online yet, doh).

You probably want to do them two at a time: make the first quaternion be the "accumulator". Now, loop: for each remaining quaternion, make sure it points into the same halfspace (dot product with accumulator is greater than 0); then add it to the accumulator. When you are done, normalize. (Watch out for the rare case when you get the 0 quaternion as a result).

This is the same as linearizing the neighborhood of the 4D sphere where all the quaternions are living; the approximation is very accurate for small angles, not quite so accurate for large angles (but not too bad either, depending on your application).

-Jonathan.

This topic is closed to new replies.

Advertisement