summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorr.ramazanov <r.ramazanov@servplus.ru>2014-04-17 07:35:26 +0200
committerr.ramazanov <r.ramazanov@servplus.ru>2014-04-17 07:35:26 +0200
commit7bcc920662ba9785b68788f61f614088e87f24e8 (patch)
tree4e5f1ecca76d5f66f288411bb8ddc7e9f4fa0c51
parentAttempted fix for the client crash with the new protocols. (diff)
downloadcuberite-7bcc920662ba9785b68788f61f614088e87f24e8.tar
cuberite-7bcc920662ba9785b68788f61f614088e87f24e8.tar.gz
cuberite-7bcc920662ba9785b68788f61f614088e87f24e8.tar.bz2
cuberite-7bcc920662ba9785b68788f61f614088e87f24e8.tar.lz
cuberite-7bcc920662ba9785b68788f61f614088e87f24e8.tar.xz
cuberite-7bcc920662ba9785b68788f61f614088e87f24e8.tar.zst
cuberite-7bcc920662ba9785b68788f61f614088e87f24e8.zip
Diffstat (limited to '')
-rw-r--r--src/Defines.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Defines.h b/src/Defines.h
index 1a8b3fa4a..9fa3b3a8e 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -493,15 +493,17 @@ inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a
inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, double & a_Pitch)
{
- if (fabs(a_X) < std::numeric_limits<double>::epsilon())
+ double r = sqrt((a_X * a_X) + (a_Z * a_Z));
+ if (r < std::numeric_limits<double>::epsilon())
{
- a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
+ a_Pan = 0;
}
else
{
- a_Pan = 0;
+ a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
}
- a_Pitch = atan2(a_Y, sqrt((a_X * a_X) + (a_Z * a_Z))) * 180 / PI;
+
+ a_Pitch = atan2(a_Y, r) * 180 / PI;
}