Any axis can be expressed by a starting point and a direction vector. Then, you can first move the axis around any axis to the original point, then rotate it, and then reverse translate the new coordinates. The problem is to calculate the new point after the vector rotates any angle through the origin point. If the unit vector is (RX, Ry, Rz), the rotation matrix is as follows:
Void rotate_point3d (float Theta, float NX, float NY, float NZ, float (& ptin) [3], float (& ptout) [3]) {float Len = sqrtf (nx * Nx + ny * ny + NZ * NZ); // unitized NX/= Len; NY/= Len; NZ/= Len; ptout [0] = ptin [0] * (cosf (theta) + NX * Nx * (1-cosf (theta ))) + // transform by matrix ptin [1] * (nx * Ny * (1-cosf (theta)-NZ * sinf (theta )) + ptin [2] * (nx * NZ * (1-cosf (theta) + ny * sinf (theta ))); ptout [1] = ptin [0] * (nx * Ny * (1-cosf (theta) + NZ * sinf (theta )) + ptin [1] * (Ny * (1-cosf (theta) + cosf (theta )) + ptin [2] * (Ny * NZ * (1-cosf (theta)-NX * sinf (theta )); ptout [2] = ptin [0] * (nx * NZ * (1-cosf (theta)-ny * sinf (theta ))) + ptin [1] * (Ny * NZ * (1-cosf (theta) + NX * sinf (theta )) + ptin [2] * (NZ * (1-cosf (theta) + cosf (theta ));}