Quaternion Camera

I’m writing a particle system for my final year project at University and
to verify that my particles are being processed correctly I’m wanting to use
a quaternion camera to rotate around the particle system.

The thing is, as I’m making my particle system a library for others to use
the camera is only for my own demonstration purposes and, as such, I don’t
want to spend a lot of research time on quaternion cameras when my
dissertation is largely based on other things =o)

My question is; Is there a decent book or tutorial which has a quick guide
to making a quaternion camera?

Currently, I have an OpenGL and SDL app which implements my particle system
library and, ideally, all I want is to be able to move the mouse and have it
rotate around a point at a specified distance.

I have found various articles that mention quaternion cameras but they all
use the mathematical functions of DirectX and as I’m writing my particle
system to be cross-platform this isn’t exactly ideal.

Game Programming Gems I has some information. You might want to find a
book specifically on quaternions, too.

Depending on your objective, you might be able to get away with
something simpler. If your trying to rotate around a fixed point where
the particle animation is (say, like the camera being a satellite and
the satellite orbiting around the world), you can create your own
model-view matrix transformation that will rotate around for you. Of
course, your not rotating around the world, your rotating around a
particle animation.

For example, translating by -N (where N = radius out from origin) out
and then rotating by X, Y, and Z axises respectively will have the
camera rotate about the origin.

i…e (From redbook)

void polarView{GLdouble distance, GLdouble twist,
GLdouble elevation, GLdouble azimuth)
{
glTranslated(0.0, 0.0, -distance);
glRotated(-twist, 0.0, 0.0, 1.0);
glRotated(-elevation, 1.0, 0.0, 0.0);
glRotated(azimuth, 0.0, 0.0, 1.0);
}

You do this translation before the modeling calls (i.e. drawing the
particle calls)

To find N (distance) programatically, it might be a little trickier.

However, if you find the bounding box of the scene, and the distance
from the center of that bounding box to one of the points, that will
give you the radius of the bounding sphere of your scene. Now, imagine
a bounding sphere around the scene. Draw this on paper. Take your
camera, extend it out, and draw two lines from the camera to the
bounding sphere until it looks like an ice cream cone. The center of
the bounding sphere to the camera is distance d. You know your field
of view, it is whatever you desire. Now, imagine a cutting plane in
the middle of the sphere, say in-between the near plane and far plane.
The extent (height) of that is twice the radius of the bounding
sphere. You can then use trig to find the distance from the camera to
the center. That should be your N. Then, knowing the radius of the
sphere, with similar triangles and knowing the distance and size of
the middle plane, you can find the near plane and far plane by
observing the near plane is distance (d - r) and the far plane is
distance (d + r), thus creating a nice tightly bound frustum for use
with gluPerspective, for use with your perspective transformation.

Note: I haven’t tried this :slight_smile: I’m still new to this field. I hope it helps.-----
Matt Johnson
Graphics Developer
VCom3D, Inc.

I’m writing a particle system for my final year project at University and to
verify that my particles are being processed correctly I’m wanting to use a
quaternion camera to rotate around the particle system.

The thing is, as I’m making my particle system a library for others to use
the camera is only for my own demonstration purposes and, as such, I don’t
want to spend a lot of research time on quaternion cameras when my
dissertation is largely based on other things =o)

My question is; Is there a decent book or tutorial which has a quick guide
to making a quaternion camera?

Currently, I have an OpenGL and SDL app which implements my particle system
library and, ideally, all I want is to be able to move the mouse and have it
rotate around a point at a specified distance.

I have found various articles that mention quaternion cameras but they all
use the mathematical functions of DirectX and as I’m writing my particle
system to be cross-platform this isn’t exactly ideal.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl