Newton quaternions past 180 degrees?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Newton quaternions past 180 degrees?

Postby Leadwerks » Thu May 03, 2018 6:27 am

I am relying heavily on render tweening in our new engine, which works great but has trouble if an angle changes 180 degrees or more in a single frame.

If I use spherical linear interpolation between two quaternions returned from Newton, will I get correct results if the difference in the two rotations is 180 degrees or more? Can a quaternion even represent a rotation greater than 360 degrees? :oops:
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Newton quaternions past 180 degrees?

Postby JoeJ » Thu May 03, 2018 10:22 am

Quaternion can represent 2 revolutions, so 720 degrees.
But personally i never used this in practice and lack experience how it affects lerp or slerp operations.

To interpolate 2 orientations one usually picks the shortest arc between them.
For animation tweening it could make sense to pick either the short but also the long arc depending on angular velocity direction.

But why don't you just integrate using current state? Newton has utility functions for this, i don't think it's much slower.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Newton quaternions past 180 degrees?

Postby Julio Jerez » Thu May 03, 2018 10:31 am

the quat interpolation in the math library assume the angle is less than 180.0
this is the correct implementation.
adding correction to teh funtion is a big mistake many programmer do, but is dead wrong
is liek when the encapsulate normalize teh check if the product is zero. but that penalizes teh entire application.
those check should be left to teh caller.

if teh case of a quat slerp is very easy to fix,
you just calculate the dot product of the two quat, and if it is negative you multiply one quat by -1

like this in pseudo code.

Code: Select all
   dFloat dot = DotProduct (q0, q1);
         if (dot < 0.0) {
              q1 = q1 * -1;
         }
        q = slerp (q0, q1, t)
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 17 guests

cron