Transformations and Rotations (quaternions)

I am having a major brain-block understanding rotations using quaternions.

What I am trying to do is the following:

  • I have a cylinder, starting at (0,0,0) and ending at (1,1,0) (basically rotated 45 degrees around z)
  • at point (1,1,0) I want to attach a 90 degree elbow (elbow has a radius R), which I want to rotate ‘theta’ angle around axis that the cylider defines
  • when rotated, I want to find out the ending coordinates of an elbow (x1, y1, z1)

So basically I am looking for a psedu-code that will give me ideas how to rotate a point using quaternions.

Thanks

Gametutorials has a tutorial on using quaternions, giving real code instead of psuedocode. Perhaps that will suit your needs?
http://www.gametutorials.com/Tutorials/OpenGL/OpenGL_Pg3.htm

I don’t think quaternions are the right thing to use here. They are great for keeping track of orientation (among other things), but not simple rotation.

So, are you looking for code that spits out numbers? If so, then OpenGL has nothing that will help you.

Do you want to render this scene? Then take a look at glRotate.

Have a look at …
www.cs.cf.ac.uk/user/G.R.Powell
->
C Code
->
quaternian

Originally posted by Jambolo:
[b]I don’t think quaternions are the right thing to use here. They are great for keeping track of orientation (among other things), but not simple rotation.

So, are you looking for code that spits out numbers? If so, then OpenGL has nothing that will help you.

Do you want to render this scene? Then take a look at glRotate.[/b]

Basically what I am trying to do is draw bended pipe in a 3D space (for straight sections I am using gluCylinder, and for bends I am drawing a part of torus also using OpenGl).
So what I am trying to do is write my positioning algorithm that calculates my starting position x,y,z, and then I rotate and transform section of a pipe into that position. That’s why I thought quaternions would be the most straight forward for my positioning algorithm.

For rotating and translating, the best bet is regular matrices. It doesnt sound like you’re doing anything strange that would require quats, which are more advanced than regular matrices.

Use glrotate and gltranslate, or at least read about them. They are matrices used to translate and rotate vertices