SLERP Is i am wrong ?

Started by
8 comments, last by apatriarca 16 years, 2 months ago
Hi Friends . I heard about SLERP in the recent days. I know the basic matrix and quaternion (still not able to understand the concept of quaternion) operations. As far i know slerp is spherical interpolation between two rotation. So this is my idea . Please see it is wrong. v1 = First direction vector ,normalized. v2 = Second direction vector,normalized. so VA = V1 X V2, will give as the axis . means if ui rotate a point in VA it will pass through both point V1 and V2. Now i can create a quaternion from VA and is possible rotate from vector V1 to V2 right ? [creating quaternion from VA]. w = cos(angle/2); x = VA.x * sin(angle/2); y = VA.y * sin(angle/2); z = VA.z * sin(angle/2); Is this a good idea or not ? Thanks good man.
Advertisement
This is not SLERP, simply because you're not interpolating between rotations, but between directions. For example, if you were to rotate an airplane with that, the roll information would simple be missing.
Thanks LtJax....
You opened my eyes....

Do you know any reference document explaining SLERP concept.
and , i also looking how quaternions works.. i know complex numbers and i could get a natural feel of understanding. But with quaternion i didn't understand that number system. The basic concept. Everyone saying quaternion is a extension to the complex number by adding more imaginary axis.. Ok. But simply i didn't understand..

Do you know any good document or web links ?
Sorry about lengthy text, i am looking for it for past days... so i am try to explain my feelings :D


If you know that they are an extension to complex numbers and/or 4d vectors, you already know as much as there is to know. The problem, I think, is that there's just no (easy) way of visualising them - unlike complex numbers, where you can just draw them to a plane.
As for all things related to math, http://mathworld.wolfram.com/ is an excellent resource. (Also your local library or wikipedia might help)

Jason Shankel wrote some great articles on quaternions in 3D graphics for the Game Programming Gems book.

If you can get your hands on the book I recommend it.

In the meantime:

http://www.gamasutra.com/features/19980703/quaternions_01.htm
http://shankel.best.vwh.net/QuatRot.html
http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/index.htm
To understand rotations using quaternions you doesn’t need to understand everything about the quaternions. But it can be useful to try to visualize them in some way.

Quaternions can be described is a lot of different way. The first way to think about them is as a vector space over R (of dimension 4). The addition of quaternions and the multiplication by R is defined as in the usual euclidean vector space R^4. The basis of that space are 1,i,j,k. Quaternions also have a multiplication defined. That operation is defined in that particular way to be able to work with that vector space like you work with reals and complex numbers (the only difference is that quaternions multiplication isn’t commutative). There isn’t any other euclidean vector space where you can define a multiplication with that properties.

Quaternions are able to represent rotations. It’s hard to see how they do it. It can be demonstrated by calculations, but I prefer to show you the topology. Consider the interval (-1,1) and the circumference centered at the origin and radius 1. Project every point of the circumference on the x-axis. At every point of the interval corresponds two points in the circumference. Now consider a disc of radius 1 and a sphere of radius 1. Project the points of the sphere on the disc and you will see that every point in the disc is in relation with two points of the sphere. The same happen with the disc in 3 dimension and the sphere in 4 dimension. Every unit quaternion is a point on S^3 (the sphere in R^4). q and -q are then related to the same point in D^2 (the inner part of the sphere in R^3) and every point in that disc can represent a rotation in R^3 (you can write these points as (angle/2Pi)*axis). It’s probably too abstract...

P.S. There is another number system, the octonions of dimension 8, but the multiplication isn’t associative. So in octonions (a*b)*c != a*(b*c). For computer graphics is useless.
Thanks apatriarca for the explanation. I am looking it now.
also Thanks LtJax , ElectricVoodoo for the nice links.

I wish i could get some understanding in quaternion working. Otherwise when i am using it in my programs , it may hurt me later..




I think the best way to get comfortable with quaternions is doing some calculation on paper.
For example:
Find the quaternions for a rotation of 60 degree around (1,1,0) and the rotation of 30 degree around the z axis. Pick up some random vectors and verifies they effectively rotate these vectors. Write the rotation as a matrix and do the same things using the matrix. Write the SLERP equation between the two rotations and see how the rotations change between the two value...
Forget about Quaternions as being 4 dimensional. I've read terrible articles explaining how a renderable Vertex is n Dimensional with X,Y,Z Nx,Ny,Nz, Cr,Cg,Cb,Ca dimensions! Unnecessary complexity.

Just think of a Quaternion as and 3D axis and an angle about that axis. Then know that the axis and angle are prescaled and normalized when represented as a Quaternion.

This is easy to understand and visualize. The Sine and Cosine scalings are not as easy to understand, but you don't really need to care about how they relate to unit circles and matrices to use them.

One more thing while I'm ranting... I've been programming video games for many years and I see Quaternions mis-used regularly. Because they were seen as 'hard to understand and complex' there is a l33t attitude to use them everywhere for everything. My opinion is to use them when they add value, that is to say, perform a useful task at an acceptable cost. Those reasons being 1) Smooth Slerp a rotation 2) Compact storage of rigid rotation. Beyond that, you should use vectors eg. Logical Forward, Up, Right, and Matrices of 4x4 or 4x3 (where bottom row/col is implied 0,0,0,1). Your life will become easy and fun and your code will run faster. I used to see nonsense like performing quaternion multiplies, then converting back and forth between matrices to make use of the results! I also saw whole game engines designed with the transform coded as a Vector3 (translation) + Quaternion (rotation). Fine, until you need to do scaling or non-uniform scaling. When asked the reason, the reply was 'I heard they are fast'.
Quaternions aren’t identified by the unit quaternions. It’s like identifying the complex numbers with the unit circle. I have thought about them as you have said for years and I’ve always found them hard to visualize and understand. Recently I have studied them in algebra and geometry courses and now I found that number system quite as natural as complex numbers or reals.

But it’s true that the majority of the things I have learned in that courses are quite useless if the only thing you want to do with them is represent a rotation. If the only think you do with quaternions is converting them to matrices than they are completely useless (you can save rotations using less memory with the angle*axis representation). So slerp is probably the only reason to use them.

This topic is closed to new replies.

Advertisement