Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / The problem with angle interpolation

Author
Message
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 25th Sep 2010 09:25 Edited at: 25th Sep 2010 09:26
I've seen a couple o' issues popping up regarding turning from one angle to another. Well... 3d euler angles are horrible, and so going from one angle smoothly to another is not easy. Just run this demo, and press the spacebar a couple of times:


The red spheres indicate the path of the end of the euler-angle interpolated stick. The green spheres indicate the path of the second stick - which uses rotation around an axis to find its path.

Notice that the red spheres sometimes follow a weird and twisted path. At the end of it all, it winds up in the same place as the green spheres destination, but the path is wildly different.

Basically, euler-interpolation is fine for short steps, but the path inbetween the start and the destination can grow wildly as the angle change gets bigger.

Screenshot for the lazy:


(edit)
and yeah all the spheres centers lie on the unit circle

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 28th Sep 2010 10:01
Well yeah, I mean the only situations in which the interpolated euler path will exactly follow the axis-angled one are when two of the euler angles are kept at zero. And, without proper measures taken to handle angle wrapping, only angles of less than 180* (of positive rotation) and that do not cross 360* will work properly. I've modified your code to demonstrate this, by only changing one angle randomly at a time (and adding WASD controls for ease):



Basically, all this goes to say that linear interpolation of euler angles should never be used for a direct route because really, it's just not how euler angles were meant to be used. When you simply add to a euler angle, it just pushes the point around one of three, although orthogonal to each other, arbitrarily oriented axes, which could very well (and often does) do absolutely nothing to help you reach point B. If you generate the appropriate quaternion on the other hand, adding or subtracting to the W value does push you along the most direct route to point B. It's kinda like cutting down a tree with a paperclip. You could use the paperclip (which was intended to keep papers neat and organized) to whittle away at the tree until it falls, but why would you do that when you can use a chainsaw?

Login to post a reply

Server time is: 2026-07-24 23:12:45
Your offset time is: 2026-07-24 23:12:45