I'm currently doing a programming project and decided to leave the easiest bit till last. however, im having some trouble with it . im sure im missing something simple.
All i want to do is take some inputted points for a triangle, and rotate them. Is the following code correct?
matrix((vertex[count][X]-mX), (vertex[count][Y]-mY));
the call is that ^
The theory is to minus the triangle mid-point (mX,mY) from the existing entered points (vertex[count][X], vertex[count][Y]). Then rotate by the matrices. Then shift back.
DEG2RAD is just the conversion factor from degrees to radians needed for sin/cos etc
Code:
void matrix(float tempx, float tempy)
{
int count;
float matrix[4]={cos(5*DEG2RAD), sin(5*DEG2RAD), -sin(5*DEG2RAD), cos(5*DEG2RAD)};
for(count=0; count<=3; count++)
{
vertex[count][X]=(matrix[0]*tempx)+(matrix[2]*tempx)+mX;
vertex[count][Y]=(matrix[1]*tempy)+(matrix[3]*tempx)+mY;
}
return;
}
Its in opengl but im not allowed to use any preritten functions for the rotation or anything
Code tags added by Hammer