Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Radian angle to Quaternion

Radian angle to Quaternion

Scheduled Pinned Locked Moved C / C++ / MFC
algorithms
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shaibee
    wrote on last edited by
    #1

    Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib

    Its never over !

    C E S 3 Replies Last reply
    0
    • S shaibee

      Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib

      Its never over !

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      shaibee wrote:

      I have a double value describing rotation angle for a text box object. I need to convert it to quaternion.

      As far as I know, a quaternion is used in 3D. So how can you convert a double which represents an angle into a 3D rotation ? You need to at least have a rotation around an axis...

      Cédric Moonen Software developer
      Charting control [v1.5] OpenGL game tutorial in C++

      S 1 Reply Last reply
      0
      • C Cedric Moonen

        shaibee wrote:

        I have a double value describing rotation angle for a text box object. I need to convert it to quaternion.

        As far as I know, a quaternion is used in 3D. So how can you convert a double which represents an angle into a 3D rotation ? You need to at least have a rotation around an axis...

        Cédric Moonen Software developer
        Charting control [v1.5] OpenGL game tutorial in C++

        S Offline
        S Offline
        shaibee
        wrote on last edited by
        #3

        Yes you are right, its to be used in 3D. I am not good in this domain. The docs for that double value say "angle in radians rotated from +ve world x-axis". Does this indicate something ? update: Now I understand that I need a vector, along with the angle for the conversion, but that vector is no where to seen in the information object for the text box. Is ther anything I can use as default for +ve world x-axis as it says above.

        Its never over !

        L 1 Reply Last reply
        0
        • S shaibee

          Yes you are right, its to be used in 3D. I am not good in this domain. The docs for that double value say "angle in radians rotated from +ve world x-axis". Does this indicate something ? update: Now I understand that I need a vector, along with the angle for the conversion, but that vector is no where to seen in the information object for the text box. Is ther anything I can use as default for +ve world x-axis as it says above.

          Its never over !

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          shaibee wrote:

          Now I understand that I need a vector, along with the angle for the conversion

          If your object is actually existing in 3D space then you should have everything you need. You can create your quaternion as follows:

          Quaternion Q;
          Q.x = x * sin(Angle/2);
          Q.y = y * sin(Angle/2);
          Q.z = z * sin(Angle/2);
          Q.w = cos(Angle/2);
          

          Best Wishes, -David Delaune

          1 Reply Last reply
          0
          • S shaibee

            Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib

            Its never over !

            E Offline
            E Offline
            El Corazon
            wrote on last edited by
            #5

            I am reminded of when I told a programmer that OpenGL didn't understand "2D". when you deal with 2D references all you are doing is nulling/zeroing the other rotations. If Z is into the screen (a common reference) then heading is your rotation of a window plane clockwise. All other references would be zero. So you can easily use 3D references to modify 2D parameters. If you write your own window compositing display a flip forward would be pitch and flip left/right is roll. you cand do some pretty cool displays. the hardest part is Euler to quaternion is reference specific. Is +Y out of the screen? is +Z into our out of the screen? so you have to watch your references. in reality you don't need to choose. If you are using only one view, one rotation, you can fake it by choosing an angle and always using that one for window rotation. You might get into trouble when you try to share, but you will find quaternions pretty lie/mistake proof as long as you are carefully consistant. I prefer thinkin in top down 3D where window rotation clockwise is Euler heading. :)

            _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

            1 Reply Last reply
            0
            • S shaibee

              Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib

              Its never over !

              S Offline
              S Offline
              Stuart Dootson
              wrote on last edited by
              #6

              Maybe this library[^] could be of use?

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups