Commit fd06e88d authored by hybrid's avatar hybrid

Code cleanup.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1421 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7e732e90
...@@ -226,27 +226,28 @@ namespace core ...@@ -226,27 +226,28 @@ namespace core
} }
//! Gets the Y and Z rotations of a vector. //! Gets the Y and Z rotations of a vector.
/** Thanks to Arras on the Irrlicht forums to add this method. /** Thanks to Arras on the Irrlicht forums for this method.
\return A vector representing the rotation in degrees of \return A vector representing the rotation in degrees of
this vector. The Z component of the vector will always be 0. */ this vector. The Z component of the vector will always be 0. */
vector3d<T> getHorizontalAngle() const vector3d<T> getHorizontalAngle() const
{ {
vector3d<T> angle; vector3d<T> angle;
angle.Y = (T)atan2(X, Z); angle.Y = (T)(atan2(X, Z) * RADTODEG64);
angle.Y *= (f32)RADTODEG64;
if (angle.Y < 0.0f) angle.Y += 360.0f; if (angle.Y < 0.0f)
if (angle.Y >= 360.0f) angle.Y -= 360.0f; angle.Y += 360.0f;
if (angle.Y >= 360.0f)
angle.Y -= 360.0f;
const f32 z1 = sqrtf(X*X + Z*Z); const f64 z1 = sqrt(X*X + Z*Z);
angle.X = (T)atan2f(z1, (f32)Y); angle.X = (T)(atan2(z1, (f64)Y) * RADTODEG64 - 90.0);
angle.X *= RADTODEG;
angle.X -= 90.0f;
if (angle.X < 0.0f) angle.X += 360.0f; if (angle.X < 0.0f)
if (angle.X >= 360.0f) angle.X -= 360.0f; angle.X += 360.0f;
if (angle.X >= 360.0f)
angle.X -= 360.0f;
return angle; return angle;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment