# 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.

## 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 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 on other sites
You are my hero for today.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633300
• Total Posts
3011266
• ### Who's Online (See full list)

There are no registered users currently online

×