# Nehe arcball error?

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

## 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 allNewRot->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 angleNewRot->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 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 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 on other sites
Quote:
 Original post by elurahuThe 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.)

1. 1
2. 2
3. 3
Rutin
17
4. 4
5. 5

• 14
• 9
• 10
• 12
• 17
• ### Forum Statistics

• Total Topics
632906
• Total Posts
3009155
• ### Who's Online (See full list)

There are no registered users currently online

×