Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quaternions' adding, subtracting and division operations on 3d models

I just dig a bit deeper in use of quaternions in 3D game programming (Yes, I know about matrices and they are OK, but we always have to learn some new things), so, we can rotate some object like this Pout = q*Pin*conjug(q), where are q is quaternion, Pin is an object of(let's say we are using some framework, where this class is defined for us) the Vector3 class, conjug(q) is the q quaternion after the its conjugating and, finally, Pout is the new Vector3's object, which we got after the rotation initial Vector3's object Pin by some angle alfa(or theta, whatever you like). Also, I know there is a way to combine rotations, like so: q_final = q2*q1 (this represents rotating by the alfa1 and then by the alfa2 angles). And, finally, dot product represents the angle between 2 quaternions in, let's say, sphere. This is clear for me. My question will concern such things as division, adding and subtracting.

My question is: Could anybody tell me, please, what are they(division, adding, subtracting -operations on quaternions) representing in a 3D programming? How they will affect on 3D model?

Thank you beforehand for your answers.

p.s. If you (DarenW, bensiu, Dharmendra, Uwe Keim, Jennis) can't understand this question, please, leave this topic. Someone might have an answer. Thank you.

like image 375
user1415536 Avatar asked Oct 30 '12 21:10

user1415536


People also ask

Why are quaternions used in 3D graphics?

Quaternions are mainly used in computer graphics when a 3D character rotation is involved. Quaternions allows a character to rotate about multiple axis simultaneously, instead of sequentially as matrix rotation allows.

How do you divide quaternions?

The same thing is true for multiplication. Division of quaternion A by quaternion B is nothing more than multiplying A by the multiplicative inverse of B. This is equivalent to the matrix form of A multiplied by the inverse of the matrix form of B.

Can quaternions be added?

Quaternion addition is simply the four-tuple addition of quaternion representations, [s1, v1] + [s2, v2] = [s1 + s2, v1 + v2]. Quaternion multiplication is defined as Equation 2.24.

What is a quaternion used for?

Quaternions are an alternate way to describe orientation or rotations in 3D space using an ordered set of four numbers. They have the ability to uniquely describe any three-dimensional rotation about an arbitrary axis and do not suffer from gimbal lock.


1 Answers

As you know, quaternions are identifiable with 4x4 real matrices. Quaternion multiplication, scalar multiplication and addition is preserved by this identification (see http://en.wikipedia.org/wiki/Quaternion#Matrix_representations). So converting two quaternions to 4x4 matrices, adding them, and converting them back is the same as just adding them. The same thing is true for multiplication.

Division of quaternion A by quaternion B is nothing more than multiplying A by the multiplicative inverse of B. This is equivalent to the matrix form of A multiplied by the inverse of the matrix form of B.

Note that rigid-body rotations (no shearing or scaling) are represented by unit length quaternions. So you can accumulate rotations by multiplying unit quaterions. Addition in this case isn't as useful.

Finally, the main reason we use quaterions in graphics is in interpolating key frames (e.g. Eberly 1999). That is, if we know the desired rotations at k positions, we can interpolate the quaterions, e.g. with a spline, resulting in a quaternion-valued curve. Each value C(t) is a unit quaternion, so it represents an intermediate rotation. Key frame interpolation is harder with homogeneous matrices because not all 4x4 matrices represent homogeneous transforms: The interpolation process may add scaling, shearing, etc.

like image 151
Codie CodeMonkey Avatar answered Nov 30 '22 22:11

Codie CodeMonkey