struct Point { double x, y, z; };
or
double Point[3];
The function prototype would then have this form:
Point Rotate(Point &P, double alpha, double beta, double gamma);
if you would like not to modify the original point and obtain another, by rotation, or
void Rotate(Point &P, double alpha, double beta, double gamma);
which would rotate the point and affect its coordinates, without creating a second point. In both versions I have considered alpha, beta and gamma to be the angles about the X, Y and Z axis. In what implementation of this function is concerned, it is easy to construct the 3D rotation matrix by first calculating sin(alpha), cos(alpha), sin(beta), cos(beta), sin(gamma), cos(gamma), storing them in separate variables, and then calculate each element of the matrix. To apply the rotation on the given point you would consider that the point forms a matrix of 3 rows and 1 column, with its elements coresponding to the 3 coordinates. Then you would do matrix multiplication between this row-matrix and the rotation matrix, which I assume would not be very difficult to do. In the end, return the new point if you have considered the first version of the prototype.
I hope this helps.
Login