Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: understanding the OpenGL matrix implementation



On Monday, December 11, 2000, at 07:27 PM, James Lee wrote:

> Greetings,
>
> I'm trying to understand OpenGL's matrix implementation. The spec
> suggests
> m[16] instead of m[i][j]. Seeing that an array starts at 0, are we
> discarding
> m[0] or m[16]?
>
> Also, this is my organizational understand. Please correct me if I'm
> wrong.
>
> the OpenGL array
>
> a e i m
> b f j n
> c g k o
> d h l p
>
> should translate to (the C convention as the red book suggests)
>
> a b c d
> e f g h
> i j k l
> m n o p

The "Blue Book" has a pretty decent explanation of the OpenGL matrix transformation stuff under the glLoadMatrix() function description.

Basically you have a matrix like this:

m[0] m[4] m[8] m[12] v[0]
m[1] m[5] m[9] m[13] v[1]
m[2] m[6] m[10] m[14] X v[2]
m[3] m[7] m[11] m[15] v[3]

The result is:

v'[0] = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3]
v'[1] = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3]
v'[2] = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3]
v'[3] = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3]

Depending on the particular 3D reference book you have, you may find either the OpenGL style "matrix times colum vector" calculation, or the "row vector times matrix" calculation.

Mathematically they are more or less the same thing for the simple case of vector*matrix, but where they begin to diverge is in how OpenGL stacks the matrix operations when you mulitply one matrix times another.

-Ken


References: 
 >understanding the OpenGL matrix implementation (From: "James Lee" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.