Advertisement Jump to content
Sign in to follow this  

Quaternion multiplication

This topic is 4883 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 have decided that it is finally time to use quaternions for the camera, however I seem to be unable to multiply quaternions or D3DX's quaternion multiplication does something more than just multiplying. Here is the *= operator, q is the const reference to the right operand. vx,vy,vz are the imaginary vector parts and w is the real part.
	float d=vx*q.vx + vy*q.vy + vz*q.vz;

	float nvx=vy*q.vz - q.vy*vz + vx*q.w + q.vx*w;
	float nvy=vz*q.vx - q.vz*vx + vy*q.w + q.vy*w;
	float nvz=vx*q.vy - q.vx*vy + vz*q.w + q.vz*w;
	w=w*q.w - d;



Share this post

Link to post
Share on other sites
Here's my guess: DirectX uses 'reversed' quaternion multiplication to be consistent with the use of row vectors, and you're using the standard form. I would try changing these lines:

float nvx = vy * q.vz - q.vy * vz + vx * q.w + q.vx * w;
float nvy = vz * q.vx - q.vz * vx + vy * q.w + q.vy * w;
float nvz = vx * q.vy - q.vx * vy + vz * q.w + q.vz * w;

To this:

float nvx = q.vy * vz - vy * q.vz + vx * q.w + q.vx * w;
float nvy = q.vz * vx - vz * q.vx + vy * q.w + q.vy * w;
float nvz = q.vx * vy - vx * q.vy + vz * q.w + q.vz * w;

And see if that fixes the problem.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!