Jump to content
  • Advertisement
Sign in to follow this  
kdworld

ArcBall Rotation

This topic is 3771 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

Hi Friends, I want to do arcball rotation , i found that most of implementations are using quaternions for rotation . (For the arbitary axis in the source sphere). It is also possible with matrices to rotate around arbitary axis. Then why quaternions are popular ? (since here we don't need any interpolation stuffs) Any nice thoughts ? KD Hard work never fails.

Share this post


Link to post
Share on other sites
Advertisement
Quaternions have a lot of nice properties. Quaternions only require 4 floats, which is a lot less than the 16 floats required for a 4x4 matrix (or 9 for a 3x3 matrix). Quaternions are also a lot faster, since a quaternion multiplication is far simpler and faster than a matrix multiplication.

Quaternions, like matrices, aren't very prone to gimbal locks. And, as you mentioned, they're useful when interpolating. The only downside to quaternions is that the math behind them can be a bit difficult to understand for some people.

Share this post


Link to post
Share on other sites
One of the more important operations involved in arcball rotation is the calculation of the rotation to perform a rotation across shortest arc between two vectors. The calculation of this value for quaternions can look something like:

d = a <dot> b;
s = sqrt((1 + d) * 2)
c = a <cross> b;
q = Quaternion(s / 2, c.x / s, c.y / s, c.z / s)

(This is missing things like error checks and special handling for when a and b are parallel.) The equivalent code for matrices is a little more involved.

Also, since arcball rotations involve storing the successive results of applied rotations, orientation is subject to numerical instability thats easier to compensate for with quaternions than with matrices.

Neither of these things are impossible with matrices, it's just easier with quaternions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!