# Quaternions???

Is there an easy way for me to implemete quaternions in c++, i need this for a varstiy project.

or is there another way to implement moving the camera (yaw pitch and roll) that isnt going to bust my brain trying to understand it?

Try looking on O’Reilly’s website. A good class for quaternions is in the Physics for Game Developers book. You can also try NeHe’s website at http://nehe.gamedev.net/. Check out Game tutorial 6 called “Free 3D Movement”.

[This message has been edited by DarthPaul (edited 10-21-2002).]

try this link. has some sample code.

http://www.gamasutra.com/features/19980703/quaternions_01.htm

Satish.

You don’t really have to know how they do what they do, but just understand what they do, then they become incredibly elegant to use.

Originally posted by iluvgfx:
[b]try this link. has some sample code.

http://www.gamasutra.com/features/19980703/quaternions_01.htm

Satish.[/b]

1. i^2 = j^2 = k^2 = -1
2. ij = k = -ji

If ij = k, then (ij)^2 = k^2, right?
=> i^2j^2 = k^2
=> (-1)
(-1) = -1
=> 1 = -1

What am I missing here?

unfortunately i know exactly how quaternions work, i am just having problems trying to apply them.

i know how the maths works but all the examples on the net that i find really seem to make them complicated,

i know how the transforms work but i dont know how to take input apply it to a transformation and then apply it to the camera

Originally posted by Humus:
If ij = k, then (ij)^2 = k^2, right?
=> i^2j^2 = k^2
=> (-1)
(-1) = -1
=> 1 = -1

What am I missing here?[/b]

(ij)^2=k^2 is ok
but (ij^2) == (ij)(ij) != (ii)(jj) !!!
In quaternion space, multiplication IS NOT commutative, as with matrices.
Actually ANY unit quaternion really represents a rotation, and vice versa.

Originally posted by Humus:

1. i^2 = j^2 = k^2 = -1
2. ij = k = -ji

If ij = k, then (ij)^2 = k^2, right?
=> i^2j^2 = k^2
=> (-1)
(-1) = -1
=> 1 = -1

What am I missing here?[/b]

Well, quaternion multiplication is not commutative!

So, here you have:
(ij)^2 == ijij == ij*(-ji) == -ijji ==

• i * (-1) * i == i*i == -1

kon

Originally posted by Brommies:
[b]unfortunately i know exactly how quaternions work, i am just having problems trying to apply them.

i know how the maths works but all the examples on the net that i find really seem to make them complicated,

i know how the transforms work but i dont know how to take input apply it to a transformation and then apply it to the camera[/b]

The NVIDIA glh helper library ( http://cvs1.nvidia.com/OpenGL/include/glh/ )might be helpful. Quaternions are implemented in glh_linear.h and for example used in glh_glut.h to implement some simple interactors.

-boyd

amerio/Kon … ah, thank, knew I was missing something, I just couldn’t see it. Looked so fundamentally flawed at first.
I haven’t worked with quaterions before, but I’m about to try it out to see if I can get smoother animation in my demo loops. Currently I’m just doing cubic interpolation between positions and Euler angles, which works decently but sometimes gives a little jerky movement if I’m not careful how I place my nodes.