# OpenGL matrix question

This topic is 3379 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
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633657
• Total Posts
3013197
×