Results 1 to 10 of 10

Thread: 3D rotation

  1. #1

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136

    Red face 3D rotation

    How do I rotate a vector by a quaternion?
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Kedaman posted something in Graphics I think...

    http://www.vbforums.com/showthread.p...6&goto=newpost
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Lively Member TB's Avatar
    Join Date
    Feb 2001
    Location
    Austria
    Posts
    106
    So what's 'quaternion', I haven't found it in my dictionary.
    Perhaps I can help you.
    mojo

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It seems to be an axis in the first 3 elements, and the last is an angle to rotate around that axis (clockwise? anticlockwise? anyone know?)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Lively Member
    Join Date
    May 2000
    Posts
    84
    A quaternion is a vector rotation angle.

    The vector part is the axis about which the vertices are rotated.
    The angle uses the right hand rule for rotation. You point your right hand thumb in the direction of the vector and your fingers curl in the positive angle direction

    Common Quaternions
    x axis D3DXQUATERNION ( 1, 0, 0, ANGLE)
    y axis D3DXQUATERNION ( 0, 1, 0, ANGLE)
    z axis D3DXQUATERNION ( 0, 0, 1, ANGLE)

    They are very usfeul for smooth movement of objects. Using a linear intepolation function you can move smoothy from one angle and rotation to another.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I'll ask my question now as well

    How do you concatenate two quaternions? (as in, you have two rotations and you want a single rotation to express that) Or isn't it possible?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Lively Member TB's Avatar
    Join Date
    Feb 2001
    Location
    Austria
    Posts
    106
    I think to concatenate 2 quaternions, you will just have to handle with the angles as if they are vectors, and then you add one to the other.
    mojo

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    hi everyone!

    nah, you don't treat quaternions as vectors, to combine rotations you do quaternion multiplication

    Q1 X Q2 = ( w1·w2 - v1·v2, w1·v2 + w2·v1 + v1xv2 )
    · is dot product and x is crossproduct
    the components w,x,y and z where:
    Q1 = w1 + x1*i + y1*j + z1*k
    Q2 = w2 + x2*i + y2*j + z2*k
    i,j and k are the unit quaternions
    and the vectors v1 and v2 are:
    v1 = (x1, y1, z1)
    v2 = (x2, y2, z2)
    simplified:
    Q1 X Q2 = (w1*w2 - x1*x2 - y1*y2 - z1*z2) + (w1*x2 + x1*w2 + y1*z2 - z1*y2)*i + (w1*y2 + y1*w2 + z1*x2 - x1*z2)*j + (w1*z2 + z1*w2 + x1*y2 - y1*x2)*k
    quaternion multiplication is not commutative
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Is it associative?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    i guess it is (i'm not sure, never tested) as long as they are in the correct order.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width