Code: Select all
vector3df Camera::getRotationDegrees(vector3df rotation) {
vector3df angle = vector3df(0.0f, 0.0f, 0.0f);
vector3df target = vector3df(0, 0, 1);
matrix4 matrix;
matrix.setRotationDegrees(rotation);
matrix.rotateVect(target);
angle.Y = atan2f(matrix[8], matrix[10]) * 180 / PI;
if (angle.Y < 0.0) { angle.Y += 360.0f; }
return angle;
}
I have tried using various combinations of matrix[8], matrix[9] and matrix[10] with the above formula to no avail. I have tried looking on the forums for a formula, but I have only found answers for the Y rotation. Other answers provide all angles, but require a matrix that is formed in a way that is not shown. The way I have listed above does not work with those formulas.
Any help is always appreciated. My thanks!