# OpenGL matrix question

This topic is 3296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, maybe this is an easy question, but i do not have much experience in equation to matrix transformations :) Here's the deal: i'm trying to create an opengl projection (dimetric) matrix. I have this 2 equations: x' = x·cos(7°) + ½ z·cos(42°) y' = y + ½ z·sin(42°) - x·sin(7°) So how does this translate to opengl matrix? So i could do this: ... glMatrixMode(GL.GL_PROJECTION); glLoadIdentity(); glOrtho(.....); double matrix[] = { // here come things from equations }; glMultMatrixd(matrix); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ...

##### Share on other sites
If you understand how a matrix is multiplied, you will see what values goes where in the matrix. For example, the resulting X-component weights the original vector's X and Z component by cos(7) and 0.5*cos(42), respectively, so stick those factors into the matrix's top row. Same for the second row for the Y-component.
double matrix[] ={    cos(7),      -sin(7),     0, 0,    0,           1,           0, 0,    0.5*cos(42), 0.5*sin(42), 0, 0,    0,           0,           0, 0,};

Just make sure you get the angles in radians, not degrees.

##### Share on other sites
damn, that was easy :D thanks a lot for reminding me!!

1. 1
2. 2
3. 3
frob
20
4. 4
Rutin
19
5. 5

• 32
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632558
• Total Posts
3007075

×