View Full Version : Quaternions???

Brommies

10-21-2002, 06:28 AM

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?

DarthPaul

10-21-2002, 07:15 AM

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).]

iluvgfx

10-21-2002, 12:16 PM

try this link. has some sample code.

you might be prompted to login. register for free.

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

Satish.

knackered

10-21-2002, 03:09 PM

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.

Humus

10-21-2002, 11:08 PM

Originally posted by iluvgfx:

try this link. has some sample code.

you might be prompted to login. register for free.

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

Satish.

It struck me will reading this article, those presented quaterion laws are AFAICS contraditory.

1) i^2 = j^2 = k^2 = -1

2) ij = k = -ji

If ij = k, then (ij)^2 = k^2, right?

=> i^2*j^2 = k^2

=> (-1)*(-1) = -1

=> 1 = -1 http://www.opengl.org/discussion_boards/ubb/confused.gif

What am I missing here?

Brommies

10-21-2002, 11:19 PM

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

amerio

10-22-2002, 12:40 AM

Originally posted by Humus:

If ij = k, then (ij)^2 = k^2, right?

=> i^2*j^2 = k^2

=> (-1)*(-1) = -1

=> 1 = -1 http://www.opengl.org/discussion_boards/ubb/confused.gif

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:

It struck me will reading this article, those presented quaterion laws are AFAICS contraditory.

1) i^2 = j^2 = k^2 = -1

2) ij = k = -ji

If ij = k, then (ij)^2 = k^2, right?

=> i^2*j^2 = k^2

=> (-1)*(-1) = -1

=> 1 = -1 http://www.opengl.org/discussion_boards/ubb/confused.gif

What am I missing here?

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:

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

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

Humus

10-22-2002, 07:55 AM

amerio/Kon .. ah, thank, knew I was missing something, I just couldn't see it. Looked so fundamentally flawed at first. http://www.opengl.org/discussion_boards/ubb/smile.gif

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.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.