What the (explitive deleted) is a Quaternion? |
cbx | What the (explitive deleted) is a Quaternion any way? I understand the x,y,z part but what could the w possible be for? Mabe if someone explained it to me I might decide to start using it, since I have seen it kicking aroung since DirectX7.
Just thought I'd ask. |
Eric Coleman | A quaternion is a complex number. It is of the form A + iB + jC + kD, where A,B,C,D are Real numbers. The imaginary numbers i,j,k are related such at i * i = j * j = k * k = -1, and i * j = k and j * i = -k. There are other variations, but this is the traditional Hamiltonian system.
A unit quaternion, its length = 1, represents a rotation in 3D cartesian space. For quaternions as related to game programming, you only work the unit quaternions. Quaternions have complex rules for mathematical operations, and often times a quaternion is represented as a grouping of a scalar and a vector. The scalar is the real coefficent, and the vector is the imaginary coefficients. It would look something like this, [A, (B,C,D)]. In most mathematical cases, the variable w is used as the real coefficient, and x,y,z are the coefficients for i,j,k respectively. The notation of a scalar and vector is used simply for ease of mathematical operations, because in this notation, some of the operations mirror traditional vector operations such as the Dot and Cross product. But in fact, quaternions were discovered long before vectors.
The use of a quaternion to transform a vector is simply the equation:
v' = qvq*
Where v' is the transformed vector caste to a quaternion, v is the original vector (also caste to a quaternion), and q and q* are the quaternion and its complex conjugate.
You might want to look at the quaternion info at [url]http://www.gamedev.net/[/url] |
cbx | Huh? What was that? In my best austin powers impression ... "ABbuuu".
What the hell kind of drugs are these mathmaticians on any way!
quote: It is of the form A + iB + jC + kD, where A,B,C,D are Real numbers.
What???? A + Zg + coagulant divided by dog sniff, What the hell does that have to with anything.
That's worse then RHW ... quote: reciprocal of homogeneous w from homogeneous coordinate (x,y,z,w).
???
I feel stupider having read that mumbo jumbo then I was before I asked the question.
I guess what i'm trying to say is SPEAK ENGLISH!
|
cbx | You know what! I'm not finished yet!
What the hell is the world comming to when we can't even stick to rotating a vector the 'natural' way.
And don't you sit there mister "Eric Coleman" and presume to tell me you know what any of that means, mister fancy schmancy cut and paste!
Huf Huf. ..
And a another thing, who the hell comes up with the names for those things anyway, Coefficent, Hamiltonian, Quaternion, reciprocal of homogeneous w! I'm getting balder with every fist full of hair!
Huf Huf Cough, Huf Huf ...
Dammit, if I ever run into that Hamiltonian guy in a dark allyway i'll hack him up and stuff him in a cooler so my parents don't see ...
Arrggg ... Chest getting tighter .... Extream pain ... Dam you Eric Coleman... dam you ... [xx(]
|
cbx | I'm alive! I'm alive! It's a miricle!
PS: My prev post was purly for entertainment value and comic relief. Or was it! Doum Doum Doum ... |
Eric Coleman | If you don't understand something, then making fun of it doesn't add any credibility to you actually wanting to learn about it. You run the risk of no one wanting to answer your questions because of your childish posts. And for the record, I did not copy and paste anything. |
cbx | OK, fair enough. But I am still left with no answer to the question, "What is a Quaternion"?
As for me I am the type who only learns something if I need to or if I find myself interested in it. For example I have never taken an active interest in database programming. I know the absolute basics of it. But I am not going to start learning about it. Why? Because I have no need for it. It is far more easier/quicker/simpler for me to save data into a file format of my own then to spend time learning how to program against SQL for axample.
Now when I draw a comparison with my lack of database knowledge, to my lack of knoledge about Quaternions you begin to see where I'm comming from. I can rotate a 3d object using vectors and matricies etc. So why do I need to learn about Quaternions?
I suspect that this is a question that many people who read these forurm posts ask. Yes there is a place for the advanced mathmatics of Quaternions etc. But that leaves the rest of us scratching our heads.
By the way I have posed this Quaternion question in fourms and new groups before so I was expecting a responce like yours. A responce that I could ... ahem ... well, poke a little fun at. When you get it you get it. But when you don't you fell as intellegent as a chimp.
As childish as it may be, if describing what a Quaternion is, means you have to dum it down so a child could understand the basics of it, then I am that child. Just don't put mathatical equasions in front of me or speak in a mathmatical tounge, before you explain what a Quaternion is used for. Otherwise there will not be a base from which to understand the math behind it.
quote: Originally posted by Eric Coleman
If you don't understand something, then making fun of it doesn't add any credibility to you actually wanting to learn about it. You run the risk of no one wanting to answer your questions because of your childish posts. And for the record, I did not copy and paste anything.
|
Chris_Poskus | quote: Originally posted by Eric Coleman
A quaternion is a complex number.
You might want to look at the quaternion info at [url]http://www.gamedev.net/[/url]
Duh... :P |
cbx | OK, for starters I already kew about the game dev site. Second I have to thank you eric because I have found that dam page I was looking for, for the past 4 months. (PS: not a page about quaternions but the game company list page. )
Lastly. Yes I have and did look at the gamedev site. I looked thru all of the articles and beginers sections and i still have not seen anything on quaternions!
So not to push my luck with you any further and to save myself any more imbarrasment. Mabe, if you are willing to, post the url of the quaternion article you believe is on the gamedev site. [:o)]
|
AT | Did you try typing quaternion into the search box ?
[url="http://www.google.com/custom?q=quaternion+&cof=T%3AFFFFFF%3BLW%3A270%3BALC%3A9999FF%3BL%3Ahttp%3A%2F%2Fwww.gamedev.net%2Fpics%2Fgdlogo2.gif%3BLC%3AFFFF96%3BLH%3A60%3BBGC%3A00000%3BAH%3Acenter%3BVLC%3AFFFF96%3BGL%3A2%3BGALT%3A9999FF%3BAWFID%3A193e74683edac795%3B&domains=GameDev.net&sitesearch=GameDev.net"]Search at gamedev.net for quaternions[/url]
Wow, look at the size of that ... |
cbx | Well you did not exactly specify to use an advanced google site search now did you! |
cbx | Whu Hoooooo! Vindication baby! Now that's what I'm talking about!
[url]http://www.gamedev.net/reference/programming/features/whyquats/page4.asp[/url]
Check out the start of the third paragraph.
quote: Software engineers, in general, are not mathematicians.
And check this out!
quote: Quaternions lend themselves well to graduate projects and technical theses. They are very complicated, so describing them (and defending them) can take many words and many pages of formulas. Vectors, by comparison, are straightforward to the point of being boring.
I love boring! I say to hell with quaternions i'm sticking to my vectors and matricies all the way! Thanks Eric you've been a great help. I now know all i need to know about quaternoins.
And lets not forget this tidbit from the faq page.
quote: 7. Have you ever written any actual code? / Do you even know anything at all about mathematics?
A. I have been writing games professionally since 1987. I have a degree in mathematics.
|
AT | quote: you did not exactly specify to use an advanced google site search
No, I said use the search box [url]http://www.gamedev.net/reference/[/url]
|
cbx | hay your not Eric coleman. I mistook you for eric, that's why I said you did not say to use google.
quote: Originally posted by AT
quote: you did not exactly specify to use an advanced google site search
No, I said use the search box [url]http://www.gamedev.net/reference/[/url]
|
Eric Coleman | AT, I fixed that big long URL you posted. It seems the google url causes the forum's automatic url recognition to go crazy. The url works now [:)]
cbx, if you look at the "articles and reference" section at Gamedev.net, you would have found the quaternion information. Here is a link to the quaternion articles. [url="http://www.gamedev.net/reference/list.asp?categoryid=28#150"]gamedev quaternion link[/url]
As for quoting the Diana Gruber article, you have been mislead. Diana Gruber doesn't know a damn thing about quaternions, and her article has been removed from the GameDev.net quaternion section because it is full of wrong information. If you look at the first page of that article, [url="http://www.gamedev.net/reference/articles/article1199.asp"]click here,[/url] you will see Gamedev.net's disclaimer.
As a final note, quaternions are not necessary for a 3D game. You can use any method of rotation you want, either Euler angles, Axis angle, spherical angles, etc. |
cbx | No eric, no! Your runining it for me! I thought I was done with those dam quaternions, then you come along and debunk her article. Arrraahhh! Why could you not leave me to my blissfull ignorence! [:(]
As for why I am sticking to my vectors and matricies any way? Because I use Direct3D to render my graphics. And it does not matter what kind of math you use to do rotations it all gets converted and stored into a matrix. And it gets storted in a matrix because that is the only relavent data type that the direct3d pipline is designed for. Weather you use quaternions or vectors for rotations, the results all get stored inside of a matrix! |
cbx | After browsing through the game dev fourms regarding Diana Gruber's "Do We Really Need Quaternions?" article It reminded me of a paragraph in her article ...
quote: Believe it or not, the quaternion vs. vector debate goes back more than 100 years. Quaternions were developed by William Rowan Hamilton around 1843 and immediately took their place in mathematical history as a solution in search of a problem. In 1901, just two years before his death, a Yale professor named Josiah Willard Gibbs published a treatise on vector algebra which included a definition of the vector dot product and vector cross product. Vector algebra was put forth as a simple, robust alternative to quaternions. Egos erupted, tempers flared, and the debate raged. Gibbs' vectors were championed posthumously by his colleague, Edwin B. Wilson, along with Oliver Heaviside in England. Quaternions were defended by Peter Guthrie Tait, but it was a losing battle. Vector algebra triumphed over its non-Euclidean predecessor, and the popularity of quaternions faded.
... The fact the the human race has been arguing about vectors verses quaternions for over 100 years is a testament to how much we humans just love to squable. |
SteveUCI | It was my understanding that the advantage of quaternions was that you can avoid gimble lock which is the "problem" that comes about when you try to rotate around more than 1 axis away from the origin.
I once worked on a little galaxy simulation (who hasn't) and rotating my view from the origin was basically as simple as rotating around the 3 axes in succession.... however once I moved away from the origin, doing that same viewpoint rotation around the 3 axes proved very problematic (hard to describe, but the results were not what was expected).
Now I haven't tried any other approaches since then (it was a long time ago when I did rotations manually in cod -- perhaps if I did what 3D hardware now does and translate the entire world toward the origin before applying viewpoint rotations it would work), but I seem to remember finding out that I had to learn about quaternions to get around the problem I was running into.
Since then, instead of learning about quaternions, I simply resigned to rotating around only the vertical axis as I moved about 3d space.
Am I way off? [:I] |
Eric Coleman | You can also use the "axis-angle" approach, which avoids gimbal lock. You would use a single axis and angle to perform the transformation. One of the nice things about quaternions is that you can interpolate between orientations smoothly, which is wonderfull for things like skeletal animation. Another power of quaternions is that you can extract the the angle of rotation very easily. To do the same thing with Euler angles is pretty much guess work because ArcSin and ArcCos only have a 180 degree range.
Of course, as you have demonstrated, if you know about gimbal lock, then you can design things to avoid it. [;)] |
cbx | Just what was gimble-lock again? Was'nt it somthing about rotations that strayed from there expected path slightly?
Another thing. Is it not true that gimble lock is irrelavant in games because the matrix that stores the rotation result gets rebuilt with the updated rotations before every rendering is done?
And one last thing ... quote: One of the nice things about quaternions is that you can interpolate between orientations smoothly, ...
... you can do that with D3D also ala Vector3.Lerp (DX9) or D3DXVec3Lerp (DX8) can't you?
|
Eric Coleman | Gimble lock is when a rotation cancels out another rotation, effectively removing a degree of freedom. If you do a 90 degree rotation along the X axis, then a 90 degree rotation around the Y axis, then you have gimble lock when trying to rotate around the Z axis because the Z is now the same thing as the X.
Lerp, aka interpolation, can be done with anything. When interpolating between two rotation matrices, the Euler interpolation creates intermediate orientations that are not the shortest path between the beginning and ending orientation. This makes the transition ugly. The quaternion path between two orientations is always the shortest path along a great circle joining those two orientations. |
cbx | Could you explain Euler interpolation? Are you refering to linear interpolation when you say this?
I am going to write some test code to try and proove you wrong about lerp, and gimble-lock, because I don't believe that is correct! |
Eric Coleman | Blending between two Euler orientations is simply interpolating between the matrices. v' = (M1 * (1-t) + M2 * t) * v Where M1 and M2 represent the two orienatation matrices, v and v' are vectors, and t is a scalar. This is just basic alpha blending; the two matrices are blended using a scalar alpha value. You should look at the quaternion example in the SDK. It shows the transition between two orientations using quaternion slerp. slerp stands for spherical linear interpolation.
As I've said before, you don't need to use quaternions in a 3D game. If you don't feel comfortable with them, then there really is no need to use them other than for very special purposes. |