Original Post
ha! this isn''t about 3D graphics. my other post wasn''t getting any attention , even though it was a problem all you hard-core programmers could solve in 3 nano seconds. here it is; its not hard (well, to me it is).
i am working on my polygon engine, and for some reason there is a delema. i
have a function that rotates a polygon, but however, whenever i pass the function
a positive angle, the polygon rotates the polygon clock-wise, and vise versa,
which is wrong. i know i can easily get around it by negating the angle, but it''s
still bothering me. heres the code (BTW, i have look-up tables for the sin and
cos functions for optimization, and i''m SURE they work):
int Rotate_Polygon(POLYGON_PTR poly, int angle)
{
int index;
if (poly->side == NULL)
{
return(-1);
}
if (angle < 0)
{
angle += 360;
}
for (index = 0; index < poly->num_sides; index++)
{
float xr = (float)poly->side[index].x1*cos_look[angle] -
(float)poly->side[index].y1*sin_look[angle];
float x2r = (float)poly->side[index].x2*cos_look[angle] -
(float)poly->side[index].y2*sin_look[angle];
float yr = (float)poly->side[index].x1*sin_look[angle] +
(float)poly->side[index].y1*cos_look[angle];
float y2r = (float)poly->side[index].x2*sin_look[angle] +
(float)poly->side[index].y2*cos_look[angle];
float cx = (float)poly->side[index].Cen_X*cos_look[angle] -
(float)poly->side[index].Cen_Y*sin_look[angle];
float cy = (float)poly->side[index].Cen_X*sin_look[angle] +
(float)poly->side[index].Cen_Y*cos_look[angle];
poly->side[index].x1 = xr;
poly->side[index].y1 = yr;
poly->side[index].x2 = x2r;
poly->side[index].y2 = y2r;
poly->side[index].Cen_X = cx;
poly->side[index].Cen_Y = cy;
}
return(1);
}