|
|
Quaternions for rotations
I've googled for info and implemented my own quaternion code but I'll be
damned if I can get the darned things to work :)
Does anyone have links to code showing how to use Quaternions to manage
rotations in an OpenGL context?
TIA
Peter.
|
|
0
|
|
|
|
Reply
|
Peter
|
2/24/2004 1:05:37 AM |
|
Peter Ashford <me@here.there.com> wrote in news:Frx_b.214$SZ.37232
@news.xtra.co.nz:
> Does anyone have links to code showing how to use Quaternions to manage
> rotations in an OpenGL context?
try www.gamedev.net
|
|
0
|
|
|
|
Reply
|
Theo
|
2/24/2004 1:55:16 AM
|
|
Peter Ashford wrote:
> I've googled for info and implemented my own quaternion code but I'll be
> damned if I can get the darned things to work :)
>
> Does anyone have links to code showing how to use Quaternions to manage
> rotations in an OpenGL context?
>
> TIA
>
> Peter.
>
Look for "trackball" in google and you'll find more.
(assuming you want to move your camera with quaternions)
Here'a a code example:
http://cvs.sourceforge.net/viewcvs.py/bzflag/bzflag/src/bzgview/Attic/Trackball.cxx?rev=1.6
Cheers,
Toni
--
for mail, mirror: ed.lausivksa@elielb
|
|
0
|
|
|
|
Reply
|
Antonio
|
2/24/2004 9:27:20 AM
|
|
> Look for "trackball" in google and you'll find more.
> (assuming you want to move your camera with quaternions)
It's orienting object that I'm after (my camera is just afixed to an
object, so that's where the issue lies for me :) )
>
> Here'a a code example:
> http://cvs.sourceforge.net/viewcvs.py/bzflag/bzflag/src/bzgview/Attic/Trackball.cxx?rev=1.6
>
>
> Cheers,
>
> Toni
>
Thank you :)
|
|
0
|
|
|
|
Reply
|
Peter
|
2/25/2004 12:02:21 AM
|
|
Peter Ashford <me@here.there.com> wrote in message news:<Frx_b.214$SZ.37232@news.xtra.co.nz>...
> I've googled for info and implemented my own quaternion code but I'll be
> damned if I can get the darned things to work :)
Double-check the docs you're using. I know some of them have the
conversion from quaternion to matrix WRONG. I'll include my code down
below for reference.
Also, careful on the order of your operations when doing successive
rotations. If you get it backwards (like I did at first-- grr), then
your objects will not rotate smoothly. Again, read the quaternion
references carefully.
Anyway, here's the code. Please don't be too mean in your criticism,
please. :-)
Note that the quaternion has members m_a, m_x, m_y, m_z (no surprise
there). The Matrix4x4 is pretty obvious too.
void Quaternion::toRotationMatrix(Matrix4x4 &m) const
{
R3DReal twoXSquared = 2.0 * m_x * m_x;
R3DReal twoYSquared = 2.0 * m_y * m_y;
R3DReal twoZSquared = 2.0 * m_z * m_z;
R3DReal twoXY = 2.0 * m_x * m_y;
R3DReal twoXZ = 2.0 * m_x * m_z;
R3DReal twoYZ = 2.0 * m_y * m_z;
R3DReal twoAX = 2.0 * m_a * m_x;
R3DReal twoAY = 2.0 * m_a * m_y;
R3DReal twoAZ = 2.0 * m_a * m_z;
m.m_matrix[m.R1C1] = 1.0 - twoYSquared - twoZSquared;
m.m_matrix[m.R1C2] = twoXY - twoAZ;
m.m_matrix[m.R1C3] = twoXZ + twoAY;
m.m_matrix[m.R2C1] = twoXY + twoAZ;
m.m_matrix[m.R2C2] = 1.0 - twoXSquared - twoZSquared;
m.m_matrix[m.R2C3] = twoYZ - twoAX;
m.m_matrix[m.R3C1] = twoXZ - twoAY;
m.m_matrix[m.R3C2] = twoYZ + twoAX;
m.m_matrix[m.R3C3] = 1.0 - twoXSquared - twoYSquared;
}
|
|
0
|
|
|
|
Reply
|
roy
|
2/25/2004 4:31:25 PM
|
|
|
4 Replies
147 Views
(page loaded in 0.082 seconds)
Similiar Articles: Quaternion and rotation about an origin and an arbitrary axis ...Quaternion and rotation about an origin and an arbitrary axis origin help tia sal22 Greetings All Thanks to James and Chas for helping me get thi... Local rotation with quaternions - comp.graphics.api.opengl ...Hi ! I've some troubles with my camera class. I use quaternion to performe rotation (interactive rotation on unit sphere with mouse). It works. But w... easiest way to store orientation and do rotations of a ball ...Also any help with rolling ball > > physics would be a big help. > > You should try to look for some information on quaternions. That's how > rotations are usually ... Is glRotate the same as axisAngle to quaternion to matrix? - comp ...Hi, What am I missing here? I have a glRotate(50, 1, 0, 0) that produces a rotation matrix. When I go from an angle axis ((50.0f * M_PI) / 180.0f), ... How to Rotate in world coords - comp.graphics.api.opengl ...Local rotation with quaternions - comp.graphics.api.opengl ... How to Rotate in world coords - comp.graphics.api.opengl ..... and rotate in Y axis doesn't make rotation in ... Suggestions for Inverse Euler Rotation - comp.soft-sys.matlab ...I am attempting to determine the Euler rotation angles (aircraft style - rotate ... fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler ... glTranslate, glRotate - comp.graphics.api.openglBut quaternions do not alter the fact that rotations and translations will produce a different affect if you change the order in which they are performed. First Person Shootemup style camera help - comp.graphics.api ...... This code is taken from my camera class and is based on // a non-FPS Quaternion ... Construct the quaternions that will represent our rotations ... Uniform random rotation matrix - comp.soft-sys.matlabRotation matrix - Wikipedia, the free encyclopedia The singularities are also avoided when working with quaternions. Uniform random rotation matrices. Generating a uniform random rotation matrix - comp.soft-sys.matlab ...Rotation matrix - Wikipedia, the free encyclopedia The singularities are also avoided when working with quaternions. Uniform random rotation matrices. Quaternions and spatial rotation - Wikipedia, the free encyclopediaUnit quaternions provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Compared to Euler angles they ... Quaternion - Wikipedia, the free encyclopediaDu Val, Patrick (1964), "Homographies, quaternions, and rotations". Oxford, Clarendon Press (Oxford mathematical monographs). LCCN 64056979 //r81 7/15/2012 9:46:16 AM
|
|
|
|
|
|
|
|
|