Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Quaternion

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2002
    Posts
    4

    Quaternion

    The quaternions that represent rotated 0 degree and 360 degrees about x should be the same or not.
    My quaternio representing rotated 0 is (w,x,y,z) = (1.0,0.0,0.0,0.0);
    and quaternion representing rotated 360 is
    (w,x,y,z) = (-1.0,0.0,0.0,0.0);

    Is that right?

    Thanks.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Quaternion

    Originally posted by piercec:
    Is that right?
    Yup, that's right

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: Quaternion

    No that is wrong. you are rotating +/- 1 degree about no axis!

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2002
    Posts
    4

    Re: Quaternion

    Originally posted by zeckensack:
    Yup, that's right
    Doesn't quaternion mean "orientation"?
    If their orientations are the same, why aren't their quaternion?

    And if I want to make a object turn 360 degrees, the 6 keyframes saving quaternions with rotation 0, 90, 180, 270, 360, 0 will success or not. I mean would there be any problem in interpolation between 360 ad 0.

    Thanks.

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2002
    Posts
    4

    Re: Quaternion

    Originally posted by Gavin:
    No that is wrong. you are rotating +/- 1 degree about no axis!
    If I want to rotate an object about x axis,
    I will convert the rotation to quaternion and multiply the quaternion with the current quaternion to get a new quaternion.

    Quaternion AxisAngleToQuaternion(int degree,float X, float Y, float Z)
    {
    Quaternion result;
    float angle = float((-degree / 180.0f) * 3.14159265);
    float buff = (float)sin( angle / 2.0f );
    result.w = (float)cos( angle / 2.0f );
    result.x = float(X * buff);
    result.y = float(Y * buff);
    result.z = float(Z * buff);
    return result;
    }
    Quaternion QRotate(tJoint joint)
    {
    Quaternion result = initQuaternion();
    Quaternion buff = initQuaternion();

    result = AxisAngleToQuaternion(joint.rot.x,1.0,0.0,0.0);
    buff = AxisAngleToQuaternion(joint.rot.y,0.0,1.0,0.0);
    result = myMultiQ(buff,result);
    buff = AxisAngleToQuaternion(joint.rot.z,0.0,0.0,1.0);
    result = myMultiQ(buff,result);
    return result;
    }
    Quaternion myMultiQ(Quaternion q1, Quaternion q2) // multiplication of two quaternions
    {
    Quaternion result;

    result.w = q1.w*q2.w - q1.x*q2.x - q1.y*q2.y - q1.z*q2.z;
    result.x = q1.w*q2.x + q1.x*q2.w + q1.y*q2.z - q1.z*q2.y;
    result.y = q1.w*q2.y - q1.x*q2.z + q1.y*q2.w + q1.z*q2.x;
    result.z = q1.w*q2.z + q1.x*q2.y - q1.y*q2.x + q1.z*q2.w;

    return result;
    }

    anything above wrong??
    I've been working in quaternion for days.


    Thank you.

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: Quaternion

    Originally posted by Gavin:
    No that is wrong. you are rotating +/- 1 degree about no axis!

    I think you just typed it wrong...

    (w,x,y,z) = (-1.0,0.0,0.0,0.0);

    this is rotating -1 (w) degrees about the axis
    (0, 0, 0).

    The quaternians are the same, really. You are rotating by 0/360 degrees so the axis could be anything and you would always end up where you started.

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: Quaternion

    There is some quat code at www.cs.cf.ac.uk/user/G.R.Powell
    ->C Code

  8. #8
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Quaternion

    Originally posted by Gavin:
    Originally posted by Gavin:
    No that is wrong. you are rotating +/- 1 degree about no axis!
    No.

    I think you just typed it wrong...

    (w,x,y,z) = (-1.0,0.0,0.0,0.0);
    this is rotating -1 (w) degrees about the axis
    (0, 0, 0).
    Here's your mistake: the w value is the cosine of half the rotation angle. It's perfectly valid this way, the cosine of 360/2=180 degrees is -1.

    This may or may not cause problems while slerping but nevertheless it is a perfectly valid unit quaternion.

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Quaternion

    Originally posted by piercec:
    Doesn't quaternion mean "orientation"?
    If their orientations are the same, why aren't their quaternion?
    Well, that's a bit over my head. Complex number stuff I guess. If you had two rotations, by 0 and by 720, these would yield the same quats.
    And if I want to make a object turn 360 degrees, the 6 keyframes saving quaternions with rotation 0, 90, 180, 270, 360, 0 will success or not. I mean would there be any problem in interpolation between 360 ad 0.
    Huge problem with a 360 turn between keyframes. Because of the normalization constraint (w*w+x*x+y*y+z*z==1) you don't have any axis information. IE w will be 1.0 in a 360 rotation, so you can't represent an axis at the same time, x y z will all be zero. So you just can't do that with a quaternion.

    Of course you need an axis for an interpolated 360 turn. A simple way around this would be to split the animation, say, into two 180 turns.

    If you do it in smaller steps anyway, you're safe

    [This message has been edited by zeckensack (edited 04-19-2002).]

    [This message has been edited by zeckensack (edited 04-19-2002).]

  10. #10
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: Quaternion

    Yeah, fine but..... what I was on about is that his x, y, z are 0. As you know this is the axis of rotation. This should be a unit vector.

Page 1 of 2 12 LastLast

Similar Threads

  1. quaternion
    By viveksrivastava in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 05-27-2013, 05:21 AM
  2. quaternion
    By kazmalak in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-09-2005, 03:43 AM
  3. Quaternion Blending
    By chemdog in forum OpenGL: General
    Replies: 0
    Last Post: 02-20-2004, 08:14 AM
  4. Quaternion (Almost done but...)
    By Erakis in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-26-2002, 06:38 PM
  5. Matrix to Quaternion
    By santyhamer in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 05-09-2001, 06:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean