summaryrefslogtreecommitdiffstats
path: root/src/Defines.h
diff options
context:
space:
mode:
authorjfhumann <j.f.humann@gmail.com>2014-04-18 21:44:58 +0200
committerjfhumann <j.f.humann@gmail.com>2014-04-18 21:44:58 +0200
commit67344a378210b1f9c21a50f02e1ff2459be66d5f (patch)
treed775281489827d49139ee3e23fba87a1d079cf89 /src/Defines.h
parentDid some static analysis, fixed some bugs and optimized a lot of code (diff)
parentAdded performance test of the nether fort generator. (diff)
downloadcuberite-67344a378210b1f9c21a50f02e1ff2459be66d5f.tar
cuberite-67344a378210b1f9c21a50f02e1ff2459be66d5f.tar.gz
cuberite-67344a378210b1f9c21a50f02e1ff2459be66d5f.tar.bz2
cuberite-67344a378210b1f9c21a50f02e1ff2459be66d5f.tar.lz
cuberite-67344a378210b1f9c21a50f02e1ff2459be66d5f.tar.xz
cuberite-67344a378210b1f9c21a50f02e1ff2459be66d5f.tar.zst
cuberite-67344a378210b1f9c21a50f02e1ff2459be66d5f.zip
Diffstat (limited to 'src/Defines.h')
-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;
}