Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / public-api / math / quaternion.cpp
index daa8960..853cb09 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,18 +40,18 @@ const Quaternion Quaternion::IDENTITY;
  * Default Constructor
  */
 Quaternion::Quaternion()
- : mVector( 0.0f, 0.0f, 0.0f, 1.0f )
+: mVector( 0.0f, 0.0f, 0.0f, 1.0f )
 {
 }
 
-Quaternion::Quaternion( float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta ) :
-  mVector( iBySineTheta, jBySineTheta, kBySineTheta, cosThetaBy2 )
+Quaternion::Quaternion( float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta )
+: mVector( iBySineTheta, jBySineTheta, kBySineTheta, cosThetaBy2 )
 {
 }
 
 Quaternion::Quaternion( const Vector4& vector )
+: mVector( vector )
 {
-  mVector = vector;
 }
 
 Quaternion::Quaternion( Radian angle, const Vector3& axis )
@@ -302,12 +302,12 @@ bool Quaternion::operator!=( const Quaternion& rhs ) const
 
 float Quaternion::Length() const
 {
-  return (float)sqrt(mVector.w * mVector.w + mVector.Dot(mVector));
+  return static_cast< float >( sqrt(mVector.w * mVector.w + mVector.Dot(mVector) ) );
 }
 
 float Quaternion::LengthSquared() const
 {
-  return (float)(mVector.w * mVector.w + mVector.Dot(mVector));
+  return static_cast< float >( mVector.w * mVector.w + mVector.Dot(mVector) );
 }
 
 void Quaternion::Normalize()
@@ -470,7 +470,7 @@ float Quaternion::AngleBetween( const Quaternion& q1, const Quaternion& q2 )
   //Formula for angle θ between two quaternion is:
   //θ = cos^−1 (2⟨q1,q2⟩^2 − 1), Where (q1,q2) is inner product of the quaternions.
   float X = from.mVector.Dot4(to.mVector);
-  float theta = acos( (2 * X * X) - 1);
+  float theta = acosf( (2 * X * X) - 1); // float arc cosine
 
   return theta;
 }
@@ -543,10 +543,9 @@ std::ostream& operator<<( std::ostream& o, const Quaternion& quaternion )
   Radian angleRadians;
 
   quaternion.ToAxisAngle( axis, angleRadians );
-  Degree degrees = Radian( angleRadians );
+  Degree degrees( angleRadians );
 
   return o << "[ Axis: [" << axis.x << ", " << axis.y << ", " << axis.z << "], Angle: " << degrees.degree << " degrees ]";
 }
 
 } // namespace Dali
-