Jump to content
  • Advertisement
Sign in to follow this  
vNistelrooy

Quaternion multiplication

This topic is 4818 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;

	vx=nvx;
	vy=nvy;
	vz=nvz;


?

Share this post


Link to post
Share on other sites
Advertisement
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 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!