Cleaned up Degree, Radian, AngleAxis and Quaternion classes 67/37067/5
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 15 Apr 2015 18:52:35 +0000 (19:52 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 16 Apr 2015 13:52:27 +0000 (14:52 +0100)
- Inline Degree, Radian and AngleAxis types to avoid unnecessary exports / export table lookups in using code
- Change AngleAxis to store a Radian angle for better accuracy
- Make Quaternion explicitly take a Radian as constructor

Change-Id: Ie359fb5a876ef395f85e8ef15857c6cc75389bef

adaptors/tizen/tilt-sensor-impl-tizen.cpp
adaptors/ubuntu/tilt-sensor-impl-ubuntu.cpp
automated-tests/src/dali-adaptor-internal/utc-Dali-ImageOperations.cpp
automated-tests/src/dali-adaptor-internal/utc-Dali-TiltSensor.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/dali-test-suite-utils.h

index 337d5dc..058abf4 100644 (file)
@@ -209,7 +209,7 @@ TiltSensor::TiltSensor()
   mSensorFrameworkHandle( -1 ),
   mRoll( 0.0f ),
   mPitch( 0.0f ),
-  mRotation( 0.0f, Vector3::YAXIS ),
+  mRotation( Radian( 0.0f), Vector3::YAXIS ),
   mRotationThreshold( 0.0f )
 {
   mRollValues.resize( NUMBER_OF_SAMPLES, 0.0f );
@@ -280,8 +280,8 @@ bool TiltSensor::Update()
   newRoll  = Clamp( float(averageRoll  / MAX_ACCELEROMETER_XY_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
   newPitch = Clamp( float(averagePitch / MAX_ACCELEROMETER_XY_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
 
-  newRotation = Quaternion( newRoll  * Math::PI * -0.5f, Vector3::YAXIS ) *
-              Quaternion( newPitch * Math::PI * -0.5f, Vector3::XAXIS );
+  newRotation = Quaternion( Radian( newRoll  * Math::PI * -0.5f ), Vector3::YAXIS ) *
+                Quaternion( Radian( newPitch * Math::PI * -0.5f ), Vector3::XAXIS );
 #endif // SENSOR_ENABLED
 
   Radian angle(Quaternion::AngleBetween(newRotation, mRotation));
index 491c1f7..482b173 100644 (file)
@@ -206,7 +206,7 @@ TiltSensor::TiltSensor()
   mSensorFrameworkHandle( -1 ),
   mRoll( 0.0f ),
   mPitch( 0.0f ),
-  mRotation( 0.0f, Vector3::YAXIS ),
+  mRotation( Dali::ANGLE_0, Vector3::YAXIS ),
   mRotationThreshold( 0.0f )
 {
   mRollValues.resize( NUMBER_OF_SAMPLES, 0.0f );
index ce51949..6643df7 100644 (file)
@@ -20,6 +20,7 @@
 #include <dali/public-api/common/ref-counted-dali-vector.h>
 
 #include <sys/mman.h>
+#include <unistd.h>
 
 using namespace Dali::Internal::Platform;
 
index d364d46..c3d6598 100644 (file)
@@ -195,8 +195,8 @@ int UtcDaliTiltSensorGetRotation(void)
 
   Quaternion rotation = sensor.GetRotation();
 
-  float roll  = sensor.GetRoll();
-  float pitch = sensor.GetPitch();
+  Radian roll( sensor.GetRoll() );
+  Radian pitch( sensor.GetPitch() );
 
   Quaternion expectedRotation = Quaternion( roll  * Math::PI * -0.5f, Vector3::YAXIS ) *
                                 Quaternion( pitch * Math::PI * -0.5f, Vector3::XAXIS );
index 081e936..450c366 100644 (file)
@@ -139,13 +139,13 @@ inline bool CompareType<Quaternion>(Quaternion q1, Quaternion q2, float epsilon)
 template <>
 inline bool CompareType<Radian>(Radian q1, Radian q2, float epsilon)
 {
-  return CompareType<float>(float(q1), float(q2), epsilon);
+  return CompareType<float>(q1.radian, q2.radian, epsilon);
 }
 
 template <>
 inline bool CompareType<Degree>(Degree q1, Degree q2, float epsilon)
 {
-  return CompareType<float>(float(q1), float(q2), epsilon);
+  return CompareType<float>(q1.degree, q2.degree, epsilon);
 }
 
 bool operator==(TimePeriod a, TimePeriod b);