Quaternions

This is a discussion on Quaternions within the Game Programming forums, part of the General Programming Boards category; Any number of the form a + bi + cj + dk where a, b, c, and d are real ...

  1. #1
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949

    Quaternions

    Any number of the form a + bi + cj + dk where a, b, c, and d are real numbers, ij = k, i2 = j2 = -1, and ij = -ji. Under addition and multiplication, quaternions have all the properties of a field, except multiplication is not commutative.
    That is what dictionary.com says about quaternions. I have read up on them to start with 3D programming, with great thanks to confuted. So where do a, b, c, d, i, j, and k come from? After I study more about these, I will most definetely have more questions, but please stick with me for it!! Thanks all !
    Do not make direct eye contact with me.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    a, b, c and d are real numbers.
    i=j=k=sqr(-1). These are defined to represent the three axes, much like vectors can be represented as a scalars times unit vectors... example:

    Code:
    | j axis (length 1)
    |
    |
    |
    L__________k axis (length 1)
    
    
    
    
        /
       /
     /
    * can be represented by a*j + b*k
    With quaternions, the axes are just i, j and k, and happen to be imaginary... So a is the real number representing the amount of rotation (usually called w when dealing with rotation...), and b, c and d (usually x, y, and z) are coefficient scalars for the i, j and k axes...


    did that make sense?
    Away.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >> i=j=k=sqr(-1)

    are you sure about that? typically in 3-space, the following is considered standard.

    i = <1,0,0>
    j = <0,1,0>
    k = <0,0,1>

    thus a*i + b*j + c*k represents the vector <a, b, c>. Using i, j, k is just another notation. At least thats how i learned it my linear algebra courses.

    >> the axes are just i, j and k, and happen to be imaginary

    i dont see why the three unit vectors would be imaginary numbers. Im not tryin to rag on you but can you show some verification of this?

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Sure enough Perspective. We're dealing with quaternions here, not just normal 3d vectors. If we were doing normal 3d vectors, you would be absolutely correct.

    Here, I wrote this for this site, which probably explains this in a bit more depth (OP mentioned that)

    From Gamasutra:

    In the eighteenth century, W. R. Hamilton devised quaternions as a four-dimensional extension to complex numbers. Soon after this, it was proven that quaternions could also represent rotations and orientations in three dimensions. There are several notations that we can use to represent quaternions. The two most popular notations are complex number notation (Eq. 1) and 4D vector notation (Eq. 2).
    From GameDev:

    A complex number is an imaginary number that is defined in terms of i, the imaginary number, which is defined such that i * i = -1.

    A quaternion is an extension of the complex number. Instead of just i, we have three numbers that are all square roots of -1, denoted by i, j, and k. This means that
    j * j = -1
    k * k = -1

    So a quaternion can be represented as
    q = w + xi + yj + zk
    where w is a real number, and x, y, and z are complex numbers.

    Another common representation is
    q=[ w,v ]
    where v = (x, y, z) is called a "vector" and w is called a "scalar". Although the v is called a vector, don't think of it as a typical 3 dimensional vector. It is a vector in 4D space, which is totally unintuitive to visualize.
    And, just for fun...
    3d Quaternions
    OpenGL tutorials
    How-to: Quaternions
    Geometric Algebra FAQ
    Some USENET thing...
    and more!

    I think I supported my case.
    Last edited by confuted; 09-05-2003 at 04:35 PM.
    Away.

  5. #5
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Thanks guys, this is a big help.
    So confuted,
    i=j=k=sqr(-1). These are defined to represent the three axes, much like vectors can be represented as a scalars times unit vectors.
    the programmer defines these, but what does he use to do so?
    Do not make direct eye contact with me.

  6. #6
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Originally posted by Lurker
    Thanks guys, this is a big help.
    So confuted,

    the programmer defines these, but what does he use to do so?
    Naw, that's just an interesting math curiosity. You don't need to worry about the imaginary parts when programming, just the real coefficients, which you can store in a float (or double).
    Code:
    struct Quaternion
    {
        float w, x, y, z;
    }
    And remember that w^2 + x^2 + y^2 + z^2 = 1 if you're programming rotations with quaternions (keep 'em normalized)

    Was something confusing in the quaternion tutorial I wrote?
    Away.

  7. #7
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Originally posted by confuted

    And remember that w^2 + x^2 + y^2 + z^2 = 1 if you're programming rotations with quaternions (keep 'em normalized)
    Sorry, but does ^ mean XOR or to the power of in this case? Sorry for my insolence!!

    Was something confusing in the quaternion tutorial I wrote?
    No, but I'm slowly moving into 3D (well I guess going from no 3D knowledge to quaternions isn't really slow ) and I'm learning the basic concept of them first. Thanks for the info tho !
    Do not make direct eye contact with me.

  8. #8
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    ^ means power in this case. I was using mathematical notation, not programming notation
    Away.

  9. #9
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    OK, that's all for now then. Thanks all !
    Do not make direct eye contact with me.

  10. #10
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    cool, thanx for the info confuted . Quaternions seem very interesting, they've definatly got my attention now. ill have to look into them sometime soon.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Rotation-- Part 2
    By satish.annauniv in forum Game Programming
    Replies: 9
    Last Post: 05-26-2008, 11:01 PM
  2. Model orientations in 3D
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 11-13-2006, 11:21 PM
  3. Camera problem: rolling
    By darksaidin in forum Game Programming
    Replies: 37
    Last Post: 08-15-2003, 08:49 AM
  4. DirectX rotation matrices
    By confuted in forum Game Programming
    Replies: 7
    Last Post: 08-10-2003, 03:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21