handmade.network » Forums » 3D rotations with 3D Gibbs vectors in place of 4D quaternions
ratchetfreak
290 posts
#12833 3D rotations with 3D Gibbs vectors in place of 4D quaternions
4 days, 15 hours ago

Procedural
ratchetfreak, I can only guess you meant that you need to check dot(g1, g2) if the angle between the Gibbs vector approaches 180°? I already said Gibbs vector interpolation is currently a real deal breaker (while an immediate rotation is as correct as quaternion one), but one can find the right weights for an exponential-like curve I posted in the screenshot above, if you weight them right you'll be able to interpolate correctly and given 181° Gibbs vector wraps to 179° in the other direction, the interpolation will always be in between 180°...


when interpolating rotations there are 2 ways you can go, the short route or the long route. Many implementations of quaternion interpolations will always pick the short route by checking if dot(q1, q2)< 0 and when true negating one of the quaternions.

instead if you do the work that test can always be false and you save yourself that test.
Procedural
30 posts
#12834 3D rotations with 3D Gibbs vectors in place of 4D quaternions
4 days, 15 hours ago Edited by on Aug. 12, 2017, 4:22 p.m.

ratchetfreak
when interpolating rotations there are 2 ways you can go, the short route or the long route. Many implementations of quaternion interpolations will always pick the short route by checking if dot(q1, q2)< 0 and when true negating one of the quaternions.

instead if you do the work that test can always be false and you save yourself that test.


Oh, exactly. Then it's a bonus point to Gibbs vectors, they simply don't have the long route. :)
cmuratori
Casey Muratori
802 posts
1 project

Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.

#12845 3D rotations with 3D Gibbs vectors in place of 4D quaternions
3 days, 2 hours ago

Procedural
Oh, exactly. Then it's a bonus point to Gibbs vectors, they simply don't have the long route. :)

No, unfortunately the exponential map actually has neither the short route or the long route. They take an erroneous (not torque-minimal) path when interpolating, and thus aren't generally suitable for arbitrary interpolation. This is another reason why you don't want to use them. Quaternions allow you to have both the short route and the long route (you want both - I can't emphasize this enough - it is a fallacy to suggest that not having the long route would be a good thing!), your choice. Quaternions also offer your choice of interpolator, since you can't have both for spherical interpolation: slerp gives you constant speed, but only 2 endpoints, whereas lerp doesn't give you constant speed but supports an arbitrary number of endpoints.

- Casey
Procedural
30 posts
#12847 3D rotations with 3D Gibbs vectors in place of 4D quaternions
2 days, 23 hours ago Edited by on Aug. 14, 2017, 8:32 a.m.

cmuratori
No, unfortunately the exponential map actually has neither the short route or the long route. They take an erroneous (not torque-minimal) path when interpolating, and thus aren't generally suitable for arbitrary interpolation. This is another reason why you don't want to use them. Quaternions allow you to have both the short route and the long route (you want both - I can't emphasize this enough - it is a fallacy to suggest that not having the long route would be a good thing!), your choice. Quaternions also offer your choice of interpolator, since you can't have both for spherical interpolation: slerp gives you constant speed, but only 2 endpoints, whereas lerp doesn't give you constant speed but supports an arbitrary number of endpoints.


I guess I should make this clear that everything you guys say about quaternions is true, no one should have a single doubt about how good quaternions for rotations are. I use them everywhere the day I realized matrices are retarded, and will keep using them because of all the things they can do.

But this thread is simply not about quaternions! :)

cmuratori
No, unfortunately the exponential map actually has neither the short route or the long route.


Wait, maybe I don't know what the short route means, because I thought it's when an angle exceeds 180° it inverses the axis and rotates 360° - angle, i.e. in other direction, to take the minimal path? This is what I see from numbers Gibbs vector shows, it's what direction example shows in the code from the first page, I can make a 3D example, but a proper fix should be found first to make interpolation work for >90° angle difference without big error accumulation.

cmuratori
They take an erroneous (not torque-minimal) path when interpolating

Not sure what you mean by "erroneous path", any path they take in any direction looks applicable for instant and <90° rotations so far, maybe I miss something.

EDIT: If it's about torque for >90° rotations (<90° rotations have torque too, but at max the error is 8°, I consider it not big, opinions may vary), I can repeat myself the third time: yes, it's a real deal breaker right now, I think maybe it has a fix I currently miss.
Procedural
30 posts
#12848 3D rotations with 3D Gibbs vectors in place of 4D quaternions
2 days, 22 hours ago

OR maybe I should stop looking for fixes for obviously broken interpolation of Gibbs vectors and admit that the only elegant and fast way to interpolate is to use a quaternion.

Then I guess the only real use of Gibbs vectors is compression, meaning for saving quaternions in compressed Gibbs form and restoring them to the short route.
ratchetfreak
290 posts
#12849 3D rotations with 3D Gibbs vectors in place of 4D quaternions
2 days, 22 hours ago

Procedural
OR maybe I should stop looking for fixes for obviously broken interpolation of Gibbs vectors and admit that the only elegant and fast way to interpolate is to use a quaternion.

Then I guess the only real use of Gibbs vectors is compression, meaning for saving quaternions in compressed Gibbs form and restoring them to the short route.


if you want compression then you can drop the magnitude of the w component without dividing the other components with them. Then just keep the sign bit or have some other way of restoring that sign bit.
Procedural
30 posts
#12850 3D rotations with 3D Gibbs vectors in place of 4D quaternions
2 days, 22 hours ago

ratchetfreak
if you want compression then you can drop the magnitude of the w component without dividing the other components with them. Then just keep the sign bit or have some other way of restoring that sign bit.

Eh, sounds like a lot of work compared to just dividing by w to compress and extracting axis and angle to decompress :)
Procedural
30 posts
#12851 3D rotations with 3D Gibbs vectors in place of 4D quaternions
2 days, 22 hours ago

On the second thought, if you encode that sign bit into one of the vector components, then it'll be faster for computer to compress and decompress than divides and atan with equal amount of space needed...