Sign in to follow this  

Nehe arcball error?

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

This topic is 2546 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this