# triangle rotation - is my logic correct?

I’m calling the glRotate… function to rotate a triangle, who’s vertices are:

v1 = {-1, -1, -2}
v2 = {-0.8, -1, -2}
v3 = {-1, -0.8, -2}

So, calling glRotate rotates the triangle by 2 degrees. Looks fine on the display.

Now, let’s say I want to compute the updated coordinates of that triangle. Would I not apply an x-axis rotation matrix to the original vertices, where the angle theta is 2 degrees?

So, the updated vertices would be approximately:

v1 = {-1, -0.9, -2.03}
v2 = {-0.8, -0.9, -2.03}
v3 = {-1, -0.73, -2.03}

Does that make sense? I just want to be sure I’m not missing anything.

Cheers.

c = cos(theta) ~= 0.99939…
s = sin(theta) ~= 0.03489…

If you are rotating around the X axis you have a matrix like that

``````   | 1 0  0|
M =| 0 c -s|
| 0 s  c|
``````

(openGL use 4x4 matrix but for rotation only we can use 3x3)
finalVertex = M * oldVertex

``````v1' = M * {-1,   -1,   -2} = { -1,   -1.06917, -1.96389 }
v2' = M * {-0.8, -1,   -2} = { -0.8, -1.06917, -1.96389 }
v3' = M * {-1,   -0.8, -2} = { -1,   -0.86929, -1.97087 }
``````

I think you are rotating in the opposite direction.