Jump to content
  • Advertisement
Sign in to follow this  
elurahu

Nehe arcball error?

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

I've recently been looking into quaternions and how they're used with respect to rotations. As part of this I've been looking at the arcball implementation shared on the Nehe site.

There's one part of the impl. I just can't seam to understand and I wanted to make sure there wasn't an error in the implementation. Funny thing is that it works obviously :)

The part where the rotation axis and angle are converted into a quaternion:


//We're ok, so return the perpendicular vector as the transform after all
NewRot->s.X = Perp.s.X;
NewRot->s.Y = Perp.s.Y;
NewRot->s.Z = Perp.s.Z;
//In the quaternion values, w is cosine (theta / 2), where theta is rotation angle
NewRot->s.W= Vector3fDot(&this->StVec, &this->EnVec);



Now this part really confuses me. Shouldn't the axis / angle be converted using sine/cos as you would normally create a rotation quat from an rot axis / angle?

Hope someone can help me shed some light on this.

Share this post


Link to post
Share on other sites
Advertisement
There are algorithms that build a unit-length rotation quaternion 'indirectly', where the resulting terms of the quaternion end up being equivalent to the 'axis*sin(theta/2), cos(theta/2)' that we usually see. I'd imagine that's what's going on here (although without seeing the code in context I can't say for sure).

Share this post


Link to post
Share on other sites
First of all thanks Jyk ;)

The axis is simply the crossproduct (rotation axis) between two unitlength vectors you want to rotate from / to, and the angle is as you can tell the angle between said vectors.

Share this post


Link to post
Share on other sites
Quote:
Original post by elurahu
The axis is simply the crossproduct (rotation axis) between two unitlength vectors you want to rotate from / to, and the angle is as you can tell the angle between said vectors.
That doesn't really cast any extra light on the code you posted. (Again, it would be easier to comment on that code if it were presented in context.)

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!