坐标旋转
1 二维坐标旋转
1 void Rotate2(double x1, double y1, double alpha, double& x2, double& y2) 2 { 3 x2 = x1 * cos(alpha) - y1 * sin(alpha); 4 y2 = x1 * sin(alpha) + y1 * cos(alpha); 5 }
2 三维坐标旋转
1 void Rotate3(double x1, double y1, double z1, 2 double alphaX,double alphaY,double alphaZ, 3 double& x2, double& y2, double& z2) 4 { 5 //Z Axis Rotation 6 double x3 = x1 * cos(alphaZ) - y1 * sin(alphaZ); 7 double y3 = x1 * sin(alphaZ) + y1 * cos(alphaZ); 8 double z3 = z1; 9 10 //Y Axis Rotation 11 double z4 = z3 * cos(alphaY) - x3 * sin(alphaY); 12 double x4 = z3 * sin(alphaY) + x3 * cos(alphaY); 13 double y4 = y3; 14 15 //X Axis Rotation 16 y2 = y4 * cos(alphaX) - z4 * sin(alphaX); 17 z2 = y4 * sin(alphaX) + z4 * cos(alphaX); 18 x2 = x4; 19 }
浙公网安备 33010602011771号