#### Archived

This topic is now archived and is closed to further replies.

# Quaternion transformation

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

## Recommended Posts

Is there a way to transform a vertex directly from a quaternion. I know I can convert the quat to a matrix and then transform the point, but that does seem redundant.

##### Share on other sites
Create a quaternion where you set the imaginary part equal to the vector and the real part to 0.
If q is the transformation quaterntion and v is the expanded vector, then the transformation is:
q v q*,
where q* is the conjugated quaternion.
Then take the imaginary part and you have your transformed 3D vector.

[edited by - VolkerG on December 4, 2002 5:01:59 PM]

##### Share on other sites
I''m sorry but I can''t understand a word of that. I''m fairly new to quaternion''s and not a big math wiz either.

##### Share on other sites
Is there a specific reason why you don''t want to use matrix transformation? If there is, then you can get your rotated/transformed vector v by:
p=(0,v)
q=(cos(a/2),u*sin(a/2))
p_rotated=q*p*q^(-1)

where a is the angle of rotation and u is the unit vector for the axis of rotation. This can be easily proven through straightforward algebra.

This method is sufficient, however you must transform every vector into a quaternion form (do a quaternion-quaternion multiplication). If you have 1000 vectors, you have to perform three operations (change of form+multiplication+change of form) 1000 times, whereas if you had a matrix you would only have to compute it once.

Good luck.

EPHERE

------------------------------------
ibmr.net

##### Share on other sites
The question was 90% curiosity and 10% implementation. Now that I know it is that much slower I probably won''t use it, but thank you very for answering my question.

##### Share on other sites
quote:
Original post by EPHERE
This method is sufficient, however you must transform every vector into a quaternion form (do a quaternion-quaternion multiplication). If you have 1000 vectors, you have to perform three operations (change of form+multiplication+change of form) 1000 times, whereas if you had a matrix you would only have to compute it once.

Why would you do that? There is no problem in computing the quaternion once as you would do with a matrix, and use it to rotate the vector.

Converting the vector to a quaternion is only stupid if you want performance. Instead, just write an inline method in the quaternion class that rotates a vector explicitly.

Simply perform the multiplication (a + bi + cj + dk)*(0 + xi + yj + zk)*(a - bi - cj - dk) by hand until you get something like: (...) + (...)i + (...)j + (...)k. The new vector's components are the coefficients in front of i, j and k respectively. It's rather tedious but not very complicated.

This will be faster than any matrix rotations, and the quaternion is less than half the size of a 3x3 matrix.

[edited by - aleph on December 5, 2002 1:48:42 PM]

##### Share on other sites
Maybe there''s something here I don''t get. I''m assuming that the x,y, and z variables there are the vector components. Are a,b,c, and d the quaternion components. Then what is i,j, and k?

##### Share on other sites
i, j and k are the counterparts to the imaginary number i in complex numers. The difference is that quaternions have three different imaginary parts.

With complex numbers i*i = -1. With quaternions you have a whole set of similar rules, namely:

i*i = j*j = k*k = -1
i*j = k
j*k = i
k*i = j
j*i = -k
k*j = -i
i*k = -j

Thus, for example (5 + 3i)*(2 + 5k) = 5*2 + 5*5k + 3i*2 + 3i*5k = 10 + 25k + 6i - 15j = (10, 6, -15, 25).

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011312
• ### Who's Online (See full list)

There are no registered users currently online

×