01: #include <math.h> 02: 03: #include "Point.h" 04: 05: #define pi 3.141592653589793 06: 07: 08: static int Round(double x) 09: { 10: if (x < 0.0f) return (int)(x - 0.5f); 11: else return (int)(x + 0.5f); 12: } 13: 14: 15: void CPoint::Rotate(int wx, int wy, int wz, double dx, double dy, double dz) 16: { 17: double cosinus, sinus, y2, x2; 18: double fx = (double)x - dx; 19: double fy = (double)y - dy; 20: double fz = (double)z - dz; 21: 22: cosinus = cos((double)wx / (double)180.0 *(double)pi); 23: sinus = sin((double)wx / (double)180.0 *(double)pi); 24: y2 = cosinus * fy - sinus * fz; 25: fz = sinus * fy + cosinus * fz; 26: fy = y2; 27: 28: cosinus = cos((double)wy / (double)180.0 * (double)pi); 29: sinus = sin((double)wy / (double)180.0 * (double)pi); 30: x2 = cosinus * fx - sinus * fz; 31: fz = sinus * fx + cosinus * fz; 32: fx = x2; 33: 34: cosinus = cos((double)wz / (double)180.0 * (double)pi); 35: sinus = sin((double)wz / (double)180.0 * (double)pi); 36: x2 = cosinus * fx - sinus * fy; 37: fy = sinus * fx + cosinus * fy; 38: fx = x2; 39: 40: x = Round(fx + dx); 41: y = Round(fy + dy); 42: z = Round(fz + dz); 43: }