Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Quaternion "creep" or Erroneous Math?

This topic is 5153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Recently I was trying to rotate a vector about an arbitrary axis via quaternions. I coded the functions and I believe (after intense review) that all of the math is correct, but there is a problem. I am attempting to rotate a unit vector that is parallel to the y-axis about the z-axis (on a black OpenGL screen, it is easiest to judge). I rotated the vector in increments of pi/6 radians, or 30 degrees. Unfortunately, the magnitude of the vector being rotated slightly changed depending on the angle at which it was being rotated. The following is a list of the vector's magnitude and corresponding rotation angle during one full rotation: (Underscores used for spacing only) Magnitude_____Degrees Rotated ---------_____--------------- 1_____________0 0.957076______30 0.945742______60 0.954033______90 0.97293_______120 0.991937______150 1_____________180 0.991937______210 0.97293_______240 0.954033______270 0.945742______300 0.957076______330 1_____________360 Due to the behavior of the magnitude per angle, I would guess that perhaps my use of the cosf and sinf functions in math.h, along with the multitude of floating point calculations, caused some inaccuracies to slip in (although, I wouldn't expect as much as .06 inaccuracy). Does this sound like a erroneous math, a common quaternion problem, or a simply "creep"ing in of inaccuracies? Any and all advice is appreciated! [edited by - liqyd on April 12, 2004 4:35:34 AM] [edited by - liqyd on April 12, 2004 4:35:58 AM] [edited by - liqyd on April 12, 2004 4:37:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
The inaccuracy seems slightly high for simple trig error, but I suppose it could be attributed to that. If you''re worried about the results, simply normalize the quaternion after each op; with a magnitude like that, though, the difference won''t be major.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
Your suggestion did help to improve the accuracy, but it turns out that wasn''t the problem. Even though I checked my math many times, a hardly noticeable error was there.

In my quaternion magnitude computing function I had something like:

SquareRoot( w^2 + ||v||)

instead of

SquareRoot( w^2 + x^2 + y^2 + z^2)

The source I am learning quaternions from had the former as the correct definition for computing quaternion magnitude, but after changing it to the latter the magnitudes are all an even 1.

Sorry for wasting space on your forum with such a stupid mistake. Again, thanks for your help.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!