Is this the correct C++ code to rotate a point in four dimensions? It's based on http://www.mosismath.com/RotationMatrix/RotationMatrix.html.
It seems that, after rotating by random angles on all six combinations of planes, whenever w is 0, the resultant w, result[3], is also 0. I don't think that's correct?
C++:
double* rotate(double x, double y, double z, double w, int plane_p, int plane_q, double angle)
{
double result[4];
double vector[4] = { x, y, z, w };
double matrix[4][4];
for (int p = 0; p < 4; p++) for (int q = 0; q < 4; q++) matrix[p][q] = 0;
for (int pq = 0; pq < 4; pq++) matrix[pq][pq] = 1;
matrix[plane_p][plane_p] = cos(angle);
matrix[plane_q][plane_q] = cos(angle);
matrix[plane_p][plane_q] = sin(angle);
matrix[plane_q][plane_p] = -sin(angle);
for (int r_i = 0; r_i < 4; r_i++)
{
double r = 0;
for (int q = 0; q < 4; q++) r += vector[r_i] * matrix[r_i][q];
result[r_i] = r;
}
return result;
}