if (vRotate < 0.0) xRotate += 180; vRotate = fmod(fabs(vRotate), 180.0); xRotate = fmod(fabs(xRotate), angle); xRotate2 = fmod(fabs(xRotate2), angle); if (vRotate >= 90.0) vRotate = 180.0 - vRotate; /*if (xRotate >= angle / 2.0) xRotate = angle - xRotate; if (xRotate2 >= angle / 2.0) xRotate2 = angle - xRotate2;*/ matrixRotate (&pTransform, xRotate, 0.0f, 1.0f, 0.0f); matrixRotate (&pTransform, vRotate, cosf (xRotate * DEG2RAD), 0.0f, sinf (xRotate * DEG2RAD)); MULTMV(pTransform.m, point); pTransform = identity; matrixRotate (&pTransform, xRotate2, 0.0f, 1.0f, 0.0f); matrixRotate (&pTransform, vRotate, cosf (xRotate2 * DEG2RAD), 0.0f, sinf (xRotate2 * DEG2RAD)); MULTMV(pTransform.m, point2); /* These lines above cause the cube to be adjusted so that the edges line up with the reflection. I know this because if I comment them out, the edges are not in line with each other. My point is, that because the reflection is just another cube, but scaled on the y axis. So instead of adjusting the cube so that it is in line with the free-rotating reflection, we instead adjust the reflection so it is in line with the free rotating cube. */