Re: Quaternions
# Re: Quaternions

**Subject**: **Re: Quaternions**
- From: Keith Bauer <email@hidden>
- Date: Fri, 28 Oct 2005 09:29:12 +1300
- Delivered-to: email@hidden
- Delivered-to: email@hidden

`I have googled quaternions and I have found many routines and various`

explainations. Anyway I cannot yet figure out how to code the main
steps.

void make_opengl_matrix_for_plane(
Plane_State *state,
float *matrix)
{
quaternion_t q = state->orientation;
vector_t p = state->position;

matrix[ 0] = 1.0f - 2.0f * q.y * q.y - 2.0f * q.z * q.z;
matrix[ 1] = 2.0f * q.x * q.y + 2.0f * q.z * q.w;
matrix[ 2] = 2.0f * q.x * q.z - 2.0f * q.y * q.w;
matrix[ 3] = 0.0f;

matrix[ 4] = 2.0f * q.x * q.y - 2.0f * q.z * q.w;
matrix[ 5] = 1.0f - 2.0f * q.x * q.x - 2.0f * q.z * q.z;
matrix[ 6] = 2.0f * q.y * q.z + 2.0f * q.x * q.w;
matrix[ 7] = 0.0f;

matrix[ 8] = 2.0f * q.x * q.z + 2.0f * q.y * q.w;
matrix[ 9] = 2.0f * q.y * q.z - 2.0f * q.x * q.w;
matrix[10] = 1.0f - 2.0f * q.x * q.x - 2.0f * q.y * q.y;
matrix[11] = 0.0f;

matrix[12] = p.x;
matrix[13] = p.y;
matrix[14] = p.z;
matrix[15] = 1.0f;
}

then glMultMatrixf(matrix);

-Keith

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
`This email sent to email@hidden
`

**References:** | |

| >**Quaternions** (From: Lorenzo <email@hidden>) |