- 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: I25bacfb011d4f24d60cabb53b7993dc51633b175
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);
{
TestApplication application;
- Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
+ Quaternion rotation( Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
Actor actor = Actor::New();
actor.SetOrientation(rotation);
Actor actor = Actor::New();
- float angle = 0.785f;
+ Radian angle( 0.785f );
Vector3 axis(1.0f, 1.0f, 0.0f);
- actor.SetOrientation(Radian( angle ), axis);
+ actor.SetOrientation( angle, axis);
Quaternion rotation( angle, axis );
// flush the queue and render once
application.SendNotification();
DALI_TEST_EQUALS(rotation, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
actor.SetOrientation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
- Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) );
+ Quaternion result( Radian( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) );
// flush the queue and render once
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( result, actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
- actor.SetOrientation(Radian( angle ), axis);
+ actor.SetOrientation( angle, axis);
// flush the queue and render once
application.SendNotification();
application.Render();
Actor actor = Actor::New();
- float angle = M_PI * 0.25f;
- actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
+ Radian angle( M_PI * 0.25f );
+ actor.RotateBy(( angle ), Vector3::ZAXIS);
// flush the queue and render once
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Quaternion( angle, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
Stage::GetCurrent().Add( actor );
- actor.RotateBy(Radian( angle ), Vector3::ZAXIS);
+ actor.RotateBy( angle, Vector3::ZAXIS);
// flush the queue and render once
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
Stage::GetCurrent().Remove( actor );
END_TEST;
Actor actor = Actor::New();
- Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS);
+ Radian angle( M_PI * 0.25f );
+ Quaternion rotation(angle, Vector3::ZAXIS);
actor.RotateBy(rotation);
// flush the queue and render once
application.SendNotification();
// flush the queue and render once
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Quaternion(angle * 2.0f, Vector3::ZAXIS), actor.GetCurrentOrientation(), 0.001, TEST_LOCATION);
END_TEST;
}
TestApplication application;
Actor actor = Actor::New();
- Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f));
+ Quaternion rotation(Radian(0.785f), Vector3(1.0f, 1.0f, 0.0f));
actor.SetOrientation(rotation);
// flush the queue and render once
application.SendNotification();
parent.Add( child );
// The actors should not have a world rotation yet
- DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( parent.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetCurrentWorldOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), 0.001, TEST_LOCATION );
application.SendNotification();
application.Render(0);
Degree d(75.0f);
AngleAxis a(d, Vector3::XAXIS);
- DALI_TEST_EQUALS(a.angle, d, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(a.angle, Radian(d), 0.001f, TEST_LOCATION);
DALI_TEST_EQUALS(a.axis, Vector3::XAXIS, 0.001f, TEST_LOCATION);
END_TEST;
}
AngleAxis a(r, Vector3::ZAXIS);
// AngleAxis stores its angle as a degree, so should only do degree comparison.
- DALI_TEST_EQUALS(a.angle, Degree(Radian(Math::PI_2)), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(a.angle, Radian(Math::PI_2), 0.001f, TEST_LOCATION);
DALI_TEST_EQUALS(a.axis, Vector3::ZAXIS, 0.001f, TEST_LOCATION);
END_TEST;
}
AngleAxis b = a;
// AngleAxis stores its angle as a degree, so should only do degree comparison.
- DALI_TEST_EQUALS(b.angle, Degree(Radian(Math::PI_2)), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(b.angle, Radian(Math::PI_2), 0.001f, TEST_LOCATION);
DALI_TEST_EQUALS(b.axis, Vector3::ZAXIS, 0.001f, TEST_LOCATION);
END_TEST;
}
AngleAxis b(a);
// AngleAxis stores its angle as a degree, so should only do degree comparison.
- DALI_TEST_EQUALS(b.angle, Degree(Radian(Math::PI_2)), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(b.angle, Radian(Math::PI_2), 0.001f, TEST_LOCATION);
DALI_TEST_EQUALS(b.axis, Vector3::ZAXIS, 0.001f, TEST_LOCATION);
END_TEST;
}
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation( Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(Radian(0.0f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
TestApplication application;
Actor actor = Actor::New();
- actor.SetOrientation(Quaternion(0.0f, Vector3::YAXIS));
+ actor.SetOrientation(Quaternion( Dali::ANGLE_0, Vector3::YAXIS ) );
Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion( Dali::ANGLE_0, Vector3::YAXIS ), ROTATION_EPSILON, TEST_LOCATION );
// Build the animation
float durationSeconds(1.0f);
try
{
- keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS));
+ keyFrames.Add(0.7f, Quaternion(Radian(1.717f), Vector3::XAXIS));
}
catch (Dali::DaliException& e)
{
KeyFrames keyFrames = KeyFrames::New();
DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION);
- keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS));
- keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS));
- keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS));
- keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f)));
+ keyFrames.Add(0.0f, Quaternion(Radian(1.717f), Vector3::XAXIS));
+ keyFrames.Add(0.2f, Quaternion(Radian(2.0f), Vector3::XAXIS));
+ keyFrames.Add(0.4f, Quaternion(Radian(3.0f), Vector3::ZAXIS));
+ keyFrames.Add(0.6f, Quaternion(Radian(4.0f), Vector3(1.0f, 1.0f, 1.0f)));
keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS));
- keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS));
+ keyFrames.Add(1.0f, Quaternion(Radian(3.0f), Vector3::YAXIS));
DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION);
application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
application.SendNotification();
- Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
+ Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
finishCheck.CheckSignalReceived();
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
+ check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
+ check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
+ check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f) );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
+ check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
// We did expect the animation to finish
application.Render(static_cast<unsigned int>(durationSeconds*500.0f)+1);
application.SendNotification();
- Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60)));
+ Quaternion check( Radian(Degree(60)), Vector3::ZAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
finishCheck.CheckSignalReceived();
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90)));
+ check = Quaternion( Radian(Degree(90)), Vector3::XAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120)));
+ check = Quaternion( Radian(Degree(120)), Vector3::XAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5)));
+ check = Quaternion( Radian(Degree(101.5)), Vector3(0.5f, 0.5f, 0.0f ) );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
application.Render(static_cast<unsigned int>(durationSeconds*250.0f)+1/* 100% progress */);
application.SendNotification();
- check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120)));
+ check = Quaternion( Radian(Degree(120)), Vector3::YAXIS );
DALI_TEST_EQUALS( actor.GetCurrentOrientation(), check, 0.001f, TEST_LOCATION );
// We did expect the animation to finish
// Default constructor, does not initialise the value
Degree degree0( 0.0f );
- // Test float assignment operator
- degree0 = 180.0f;
- DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION );
+ // Test assignment operator
+ degree0 = Degree(180.0f);
+ DALI_TEST_EQUALS( degree0.degree, 180.0f, 0.001f, TEST_LOCATION );
// Constructor from float value
Degree degree1( 180.0f );
- DALI_TEST_EQUALS( float(degree1), 180.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( degree1.degree, 180.0f, 0.001f, TEST_LOCATION );
// Constructor from a Radian
Degree degree2( Radian( Math::PI ) );
- DALI_TEST_EQUALS( float(degree2), 180.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( degree2.degree, 180.0f, 0.001f, TEST_LOCATION );
- // Assignment from Radian
- Degree degree3( 0.0f );
- degree3 = Radian( Math::PI );
- DALI_TEST_EQUALS( float(degree3), 180.0f, 0.001f, TEST_LOCATION );
END_TEST;
}
{
TestApplication application;
- // Comparison between radians
+ // Comparison between degrees
Degree degree0( 90.0f );
Degree degree1( 90.0f );
Degree degree2( 180.0f );
Degree degree4( 90.0f );
Radian radian0( Math::PI );
- DALI_TEST_CHECK( degree3 == radian0 );
- DALI_TEST_CHECK( degree4 != radian0 );
+ DALI_TEST_CHECK( degree3 == Degree(radian0) );
+ DALI_TEST_CHECK( degree4 != Degree(radian0) );
// Comparison with float
Degree degree5( 90.0f );
- DALI_TEST_CHECK( degree5 == 90.0f );
- DALI_TEST_CHECK( degree5 != 180.0f );
+ DALI_TEST_CHECK( degree5.degree == 90.0f );
+ DALI_TEST_CHECK( degree5.degree != 180.0f );
END_TEST;
}
-
-// test case for cast operators
-int UtcDaliDegreeCastOperators01(void)
-{
- TestApplication application; // Exceptions require TestApplication
-
- Degree degree0( 180.0f );
-
- const float& value0( degree0 );
- DALI_TEST_EQUALS( value0, 180.0f, 0.001f, TEST_LOCATION );
-
- degree0 = 90.0f;
- DALI_TEST_EQUALS( value0, 90.0f, 0.001f, TEST_LOCATION );
-
- float& value1( degree0 );
- DALI_TEST_EQUALS( value1, 90.0f, 0.001f, TEST_LOCATION );
-
- value1 = 180.0f;
- DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION );
- END_TEST;
-}
-
-
-
-int UtcDaliDegreeCastOperatorEquals(void)
+int UtcDaliDegreeOperatorEquals(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliDegreeCastOperatorNotEquals(void)
+int UtcDaliDegreeOperatorNotEquals(void)
{
TestApplication application;
DALI_TEST_EQUALS(a != c, true, TEST_LOCATION);
END_TEST;
}
-
-int UtcDaliDegreeCastOperatorLessThan(void)
-{
- TestApplication application;
-
- Degree a(45.0f);
- Degree b(90.0f);
- Degree c(180.0f);
- Degree d(360.0f);
- Degree e(-180.0f);
-
- DALI_TEST_EQUALS(a < a, false, TEST_LOCATION);
- DALI_TEST_EQUALS(a < b, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a < c, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a < d, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a < e, false, TEST_LOCATION);
-
- DALI_TEST_EQUALS(b < a, false, TEST_LOCATION);
- DALI_TEST_EQUALS(b < b, false, TEST_LOCATION);
- DALI_TEST_EQUALS(c < b, false, TEST_LOCATION);
- DALI_TEST_EQUALS(d < b, false, TEST_LOCATION);
- DALI_TEST_EQUALS(e < b, true, TEST_LOCATION);
- END_TEST;
-}
for (int i=0;i<1000;++i)
{
float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f) );
axis.Normalize();
- m.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), Vector3::ZERO );
+ m.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), Vector3::ZERO );
m.OrthoNormalize();
}
for (int i=0;i<1000;++i)
{
float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
axis.Normalize();
Vector3 center(10.0f, 15.0f, 5.0f);
Matrix m0;
m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center );
+ m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
Matrix m1(m0);
m1.OrthoNormalize();
for (int i=0;i<1000;++i)
{
float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
axis.Normalize();
Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f);
Matrix m0;
m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center );
+ m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
Matrix m1(m0);
m1.Invert();
for (int i=0;i<1000;++i)
{
float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
axis.Normalize();
Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f);
Matrix m0;
m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center );
+ m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
Matrix m1;
m0.InvertTransform(m1);
Matrix m1(rotation1);
Matrix result1(false);
- Vector4 vForward4(vForward.x, vForward.y, vForward.z, 0.0f);
- result1.SetTransformComponents( Vector3::ONE, Quaternion(Radian(Degree(angle)), vForward4), Vector3::ZERO );
+ Vector3 vForward3(vForward.x, vForward.y, vForward.z);
+ result1.SetTransformComponents( Vector3::ONE, Quaternion(Radian(Degree(angle)), vForward3), Vector3::ZERO );
DALI_TEST_EQUALS(m1, result1, 0.001, TEST_LOCATION);
value = Property::Value( AngleAxis( Radian(Math::PI_2), Vector3::XAXIS ));
value.Get(aa);
Quaternion r8(Radian(Degree(aa.angle)), aa.axis);
- DALI_TEST_EQUALS(r8, Quaternion(Math::PI_2, Vector3::XAXIS), 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(r8, Quaternion(Radian(Math::PI_2), Vector3::XAXIS), 0.001, TEST_LOCATION);
std::string s = "no";
value = Property::Value("yes");
{
TestApplication application; // Reset all test adapter return codes
- Quaternion r(M_PI/2.0f, Vector4(1.0f, 2.0f, 3.0f, M_PI/3.0f));
+ Quaternion r( Radian(Math::PI_2), Vector3( 1.0f, 2.0f, 3.0f ));
// This will be normalised:
- DALI_TEST_EQUALS(r.AsVector().w, 0.707f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(r.AsVector().x, 0.189f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(r.AsVector().y, 0.378f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(r.AsVector().z, 0.567f, 0.001, TEST_LOCATION);
TestApplication application; // Reset all test adapter return codes
// Test from euler angles
- Quaternion e1(Radian(Degree(45)), 0.0f, 0.0f);
+ Quaternion e1( Radian(Degree(45)), Radian(0.0f), Radian(0.0f) );
Vector4 r1(0.383f, 0.0f, 0.0f, 0.924f);
- Quaternion e2(0.0f, Radian(Degree(75)), 0.0f);
+ Quaternion e2( Radian(0.0f), Radian(Degree(75)), Radian(0.0f) );
Vector4 r2(0.0f, 0.609f, 0.0f, 0.793f);
- Quaternion e3(0.0f, 0.0f, Radian(Degree(135)));
+ Quaternion e3( Radian(0.0f), Radian(0.0f), Radian(Degree(135)) );
Vector4 r3(0.0f, 0.0f, 0.924f, 0.383f);
- Quaternion e4(Radian(Degree(71)), Radian(Degree(36)), Radian(Degree(27)));
+ Quaternion e4(Radian(Degree(71)), Radian(Degree(36)), Radian(Degree(27)) );
Vector4 r4(0.478f, 0.374f, 0.006f, 0.795f);
- Quaternion e5(Radian(Degree(-31)), Radian(Degree(-91)), Radian(Degree(-173)));
+ Quaternion e5(Radian(Degree(-31)), Radian(Degree(-91)), Radian(Degree(-173)) );
Vector4 r5(-0.697f, 0.145f, -0.686f, -0.149f);
DALI_TEST_EQUALS(e1.AsVector(), r1, 0.001, TEST_LOCATION);
}
-int UtcDaliQuaternionFromAxisAngle(void)
-{
- TestApplication application; // Reset all test adapter return codes
-
- Quaternion q = Quaternion::FromAxisAngle(Vector4(1.0f, 2.0f, 3.0f, M_PI/3.0f), M_PI/2.0f);
-
- Quaternion r(0.707f, 0.189f, 0.378f, 0.567f);
-
- DALI_TEST_EQUALS(q, r, 0.001, TEST_LOCATION);
- END_TEST;
-}
-
int UtcDaliQuaternionToAxisAngle01(void)
{
TestApplication application; // Reset all test adapter return codes
Quaternion q(0.932f, 1.1f, 3.4f, 2.7f);
- float angle;
+ Radian angle;
Vector3 axis;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, true, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, 0.74f, 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, 0.74f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 3.03f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 9.38f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 7.45f, 0.01f, TEST_LOCATION);
{
TestApplication application; // Reset all test adapter return codes
Quaternion q(0.932f, 1.1f, 3.4f, 2.7f);
- float angle;
- Vector4 axis;
+ Radian angle;
+ Vector3 axis;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, true, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, 0.74f, 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, 0.74f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 3.03f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 9.38f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 7.45f, 0.01f, TEST_LOCATION);
- DALI_TEST_EQUALS(axis.w, 0.0f, 0.01f, TEST_LOCATION);
END_TEST;
}
{
TestApplication application; // Reset all test adapter return codes
Quaternion q(1, 2, 3, 4);
- float angle;
+ Radian angle;
Vector3 axis;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, false, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, 0.0f, 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, 0.0f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 0.0f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 0.0f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 0.0f, 0.01f, TEST_LOCATION);
{
TestApplication application; // Reset all test adapter return codes
Quaternion q(1, 2, 3, 4);
- float angle;
- Vector4 axis;
+ Radian angle;
+ Vector3 axis;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, false, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, 0.0f, 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, 0.0f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 0.0f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 0.0f, 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 0.0f, 0.01f, TEST_LOCATION);
- DALI_TEST_EQUALS(axis.w, 0.0f, 0.01f, TEST_LOCATION);
END_TEST;
}
{
TestApplication application; // Reset all test adapter return codes
- Quaternion q(0.69813, Vector4(1.0f, 0.0f, 0.0f, 0.0f)); // 40 degree rotation around X axis
+ Quaternion q( Radian(0.69813), Vector3(1.0f, 0.0f, 0.0f) ); // 40 degree rotation around X axis
// Result calculated using a different maths library (with appropriate row/col ordering)
TestApplication application; // Reset all test adapter return codes
// rotation around arbitrary axis
- Quaternion q2(-1.23918f, Vector4(7.0f, -13.0f, 11.0f, 0.0f));
+ Quaternion q2( Radian(-1.23918f), Vector3(7.0f, -13.0f, 11.0f) );
float els[] = { 0.423f, -0.746f, -0.514f, 0.00f,
0.384f, 0.662f, -0.644f, 0.00f,
{
TestApplication app;
- Quaternion q(0.0f, Vector3(5.0f, 6.0f, 7.0f));
+ Quaternion q( Radian( 0.0f ), Vector3(5.0f, 6.0f, 7.0f) );
// q.w is non-zero. Should assert.
try
int UtcDaliQuaternionLog01(void)
{
TestApplication application; // Reset all test adapter return codes
- Quaternion q(Math::PI*0.73f, Vector3(2,3,4));
+ Quaternion q( Radian( Math::PI*0.73f ), Vector3(2,3,4) );
Quaternion q2 = q;
q2.Normalize();
{
TestApplication application;
- Quaternion q1(M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f));
- Quaternion q2(-M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f));
+ Quaternion q1(Radian(M_PI/4.0f), Vector3(0.0f, 0.0f, 1.0f));
+ Quaternion q2(Radian(-M_PI/4.0f), Vector3(0.0f, 0.0f, 1.0f));
Quaternion q = Quaternion::Slerp(q1, q2, 0.0f);
DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION);
// @ 25%, will be at M_PI/8
q = Quaternion::Slerp(q1, q2, 0.25f);
- Vector4 axis;
- float angle;
+ Vector3 axis;
+ Radian angle;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, true, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, Math::PI/8.0f, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, Math::PI/8.0f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 0.0f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 0.0f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 1.0f, 0.001, TEST_LOCATION);
{
TestApplication application;
- Quaternion q1(M_PI/6, Vector3(0.0f, 0.0f, 1.0f));
- Quaternion q2(M_PI/2, Vector3(0.0f, 0.0f, 1.0f));
+ Quaternion q1( Dali::ANGLE_30, Vector3(0.0f, 0.0f, 1.0f));
+ Quaternion q2( Dali::ANGLE_90, Vector3(0.0f, 0.0f, 1.0f));
Quaternion q = Quaternion::Slerp(q1, q2, 0.0f);
// @ 50%, will be at M_PI/3 around z
q = Quaternion::Slerp(q1, q2, 0.5f);
- Quaternion r( M_PI/3, Vector3( 0.0f, 0.0f, 1.0f));
+ Quaternion r( Dali::ANGLE_120, Vector3( 0.0f, 0.0f, 1.0f));
DALI_TEST_EQUALS( q, r, 0.001, TEST_LOCATION );
END_TEST;
}
DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION);
q = Quaternion::Slerp(q1, q2, 0.05f);
- Vector4 axis;
- float angle;
+ Vector3 axis;
+ Radian angle;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, true, TEST_LOCATION);
DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION);
q = Quaternion::Slerp(q1, q2, 0.5f);
- Vector4 axis;
- float angle;
+ Vector3 axis;
+ Radian angle;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, true, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, float(Radian(Degree(125))), 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, float(Radian(Degree(125))), 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 0.0f, 0.01, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 0.0f, 0.01, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 1.0f, 0.01, TEST_LOCATION);
{
TestApplication application;
- Quaternion q1(M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f));
- Quaternion q2(-M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f));
+ Quaternion q1( Dali::ANGLE_45, Vector3(0.0f, 0.0f, 1.0f));
+ Quaternion q2(-Dali::ANGLE_45, Vector3(0.0f, 0.0f, 1.0f));
Quaternion q = Quaternion::SlerpNoInvert(q1, q2, 0.0f);
DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION);
// @ 25%, will be at M_PI/8
q = Quaternion::SlerpNoInvert(q1, q2, 0.25f);
- Vector4 axis;
- float angle;
+ Vector3 axis;
+ Radian angle;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, true, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, Math::PI/8.0f, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, Math::PI/8.0f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 0.0f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 0.0f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 1.0f, 0.001, TEST_LOCATION);
DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION);
q = Quaternion::SlerpNoInvert(q1, q2, 0.5f);
- Vector4 axis;
- float angle;
+ Vector3 axis;
+ Radian angle;
bool converted = q.ToAxisAngle(axis, angle);
DALI_TEST_EQUALS(converted, true, TEST_LOCATION);
- DALI_TEST_EQUALS(angle, float(Radian(Degree(125))), 0.01f, TEST_LOCATION);
+ DALI_TEST_EQUALS(angle.radian, float(Radian(Degree(125))), 0.01f, TEST_LOCATION);
DALI_TEST_EQUALS(axis.x, 0.0f, 0.01, TEST_LOCATION);
DALI_TEST_EQUALS(axis.y, 0.0f, 0.01, TEST_LOCATION);
DALI_TEST_EQUALS(axis.z, 1.0f, 0.01, TEST_LOCATION);
// Don't know what actual value should be, but can make some informed guesses.
q = Quaternion::Squad(q1, q2, q1out, q2in, 0.5f);
- float angle;
+ Radian angle;
Vector3 axis;
q.Normalize();
q.ToAxisAngle(axis, angle);
q = -q; // Might get negative quat
q.ToAxisAngle(axis, angle);
}
- float deg = Degree(Radian(angle));
+ float deg = Degree(angle).degree;
DALI_TEST_CHECK(deg >= 0 && deg <= 90);
DALI_TEST_CHECK(axis.y > 0);
DALI_TEST_CHECK(axis.z > 0);
{
TestApplication application; // Reset all test adapter return codes
- Quaternion q1(Radian(Degree(45)), 0.0f, 0.0f);
- Quaternion q2(Radian(Degree(47)), 0.0f, 0.0f);
+ Quaternion q1( ANGLE_45, ANGLE_0, ANGLE_0 );
+ Quaternion q2(Radian(Degree(47)), ANGLE_0, ANGLE_0 );
DALI_TEST_EQUALS(Quaternion::AngleBetween(q1, q2), fabsf(Radian(Degree(45)) - Radian(Degree(47))), 0.001f, TEST_LOCATION);
Quaternion q3(Radian(Degree(80)), Vector3::YAXIS);
std::ostringstream oss;
- Quaternion quaternion(M_PI, Vector3::YAXIS);
+ Quaternion quaternion( Dali::ANGLE_180, Vector3::YAXIS );
oss << quaternion;
Radian radian4( Math::PI_2 );
Degree degree0( 180.0f );
- DALI_TEST_CHECK( radian3 == degree0 );
- DALI_TEST_CHECK( radian4 != degree0 );
+ DALI_TEST_CHECK( radian3 == Radian(degree0) );
+ DALI_TEST_CHECK( radian4 != Radian(degree0) );
// Comparison with float
Radian radian5( Math::PI_2 );
Radian radian0( Math::PI );
- const float& value0( radian0 );
+ const float& value0( radian0.radian );
DALI_TEST_EQUALS( value0, Math::PI, 0.001f, TEST_LOCATION );
radian0 = Math::PI_2;
DALI_TEST_EQUALS( value0, Math::PI_2, 0.001f, TEST_LOCATION );
- float& value1( radian0 );
+ float value1( radian0 );
DALI_TEST_EQUALS( value1, Math::PI_2, 0.001f, TEST_LOCATION );
- value1 = Math::PI;
+ radian0 = Math::PI;
DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION );
END_TEST;
}
Radian b(Math::PI_2);
Radian c(Math::PI);
- DALI_TEST_EQUALS(a == a, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a == b, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a == c, false, TEST_LOCATION);
+ DALI_TEST_EQUALS( a == a, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( a == b, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( a == c, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( Degree(c) == c, true, TEST_LOCATION );
END_TEST;
}
Radian b(Math::PI_2);
Radian c(Math::PI);
- DALI_TEST_EQUALS(a != a, false, TEST_LOCATION);
- DALI_TEST_EQUALS(a != b, false, TEST_LOCATION);
- DALI_TEST_EQUALS(a != c, true, TEST_LOCATION);
+ DALI_TEST_EQUALS( a != a, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( a != b, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( a != c, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( Degree(a) != c, true, TEST_LOCATION );
END_TEST;
}
DALI_TEST_EQUALS(d < b, false, TEST_LOCATION);
DALI_TEST_EQUALS(e < b, true, TEST_LOCATION);
- DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(180.0f), true, TEST_LOCATION);
- DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(90.0f), false, TEST_LOCATION);
- DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(45.0f), false, TEST_LOCATION);
+ DALI_TEST_EQUALS( Radian(Math::PI_2) < Degree(180.0f), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( Radian(Math::PI_2) < Degree(90.0f), false, TEST_LOCATION);
+ DALI_TEST_EQUALS( Radian(Math::PI_2) > Degree(45.0f), true, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( Degree(180.0f) > Radian(Math::PI_2), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( Degree(90.0f) > Radian(Math::PI_2), false, TEST_LOCATION);
+ DALI_TEST_EQUALS( Degree(45.0f) < Radian(Math::PI_2), true, TEST_LOCATION);
+
END_TEST;
}
TestApplication application;
Vector3 vec3(Vector3::YAXIS);
- Quaternion rotation(Math::PI_2, Vector3::ZAXIS);
+ Quaternion rotation( Dali::ANGLE_90, Vector3::ZAXIS );
Vector3 result(-Vector3::XAXIS);
vec3 *= rotation;
DALI_TEST_EQUALS( vec3, result, 0.001, TEST_LOCATION );
std::ostringstream oss;
Vector3 axis;
- float angle;
+ Radian angle;
q.ToAxisAngle(axis, angle);
oss << std::setw(indent+3) << std::setfill(' ') << std::setprecision(precision) << std::right;
- oss << "<A:" << std::setw(precision+4) << angle * 180.0 / Math::PI << ", " << Vector3ToString(axis, precision, 0) << ">";
+ oss << "<A:" << std::setw(precision+4) << Degree( angle ).degree << ", " << Vector3ToString(axis, precision, 0) << ">";
return oss.str();
}
void Actor::SetOrientation( const Radian& angle, const Vector3& axis )
{
- Vector4 normalizedAxis( axis.x, axis.y, axis.z, 0.0f );
+ Vector3 normalizedAxis( axis.x, axis.y, axis.z );
normalizedAxis.Normalize();
- Quaternion orientation( Quaternion::FromAxisAngle( normalizedAxis, angle ) );
+ Quaternion orientation( angle, normalizedAxis );
SetOrientation( orientation );
}
// By default Actors face in the positive Z direction in world space
// CameraActors should face in the negative Z direction, towards the other actors
- actor->SetOrientation( Quaternion( Math::PI, Vector3::YAXIS ) );
+ actor->SetOrientation( Quaternion( Dali::ANGLE_180, Vector3::YAXIS ) );
return actor;
}
inline void Interpolate (AngleAxis& result, const AngleAxis& a, const AngleAxis& b, float progress)
{
- Quaternion q1(Radian(a.angle), a.axis);
- Quaternion q2(Radian(b.angle), b.axis);
+ Quaternion q1(a.angle, a.axis);
+ Quaternion q2(b.angle, b.axis);
Quaternion iq = Quaternion::Slerp(q1, q2, progress);
iq.ToAxisAngle(result.axis, result.angle);
if( mViewMode == MONO )
{
- mDefaultCamera->SetOrientation( Degree( 180.0f ), Vector3::YAXIS );
+ mDefaultCamera->SetOrientation( Dali::ANGLE_180, Vector3::YAXIS );
mRenderTaskList->GetTask(0).SetSourceActor( Dali::Actor() );
//Create camera and RenderTask for left eye
mDefaultCamera->Remove( *mRightCamera.Get() );
mRightRenderTask.Reset();
mRightCamera.Reset();
-
- mDefaultCamera->SetOrientation( Degree( 0.0f ), Vector3::YAXIS );
+ mDefaultCamera->SetOrientation( Dali::ANGLE_0, Vector3::YAXIS );
mDefaultCamera->SetType( Dali::Camera::LOOK_AT_TARGET );
mRenderTaskList->GetTask(0).SetSourceActor( Dali::Layer(mRootLayer.Get()) );
mLeftCamera->SetPerspectiveProjection( mSize, Vector2( 0.0f,stereoBase) );
mLeftCamera->SetAspectRatio( aspect );
- mLeftCamera->SetOrientation( Degree(-90.0f), Vector3::ZAXIS );
+
+ mLeftCamera->SetOrientation( -Dali::ANGLE_90, Vector3::ZAXIS );
mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
mLeftRenderTask.SetViewport( Viewport(0, mSize.height * 0.5f, mSize.width, mSize.height * 0.5f) );
mRightCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, -stereoBase) );
mRightCamera->SetAspectRatio( aspect );
- mRightCamera->SetOrientation( Degree(-90.0f), Vector3::ZAXIS );
+ mRightCamera->SetOrientation( -Dali::ANGLE_90, Vector3::ZAXIS );
mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
mRightRenderTask.SetViewport( Viewport(0, 0, mSize.width, mSize.height * 0.5f ) );
mLeftCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(stereoBase,0.0f) );
mLeftCamera->SetFieldOfView( fov );
- mLeftCamera->SetOrientation( Degree(0.0f), Vector3::ZAXIS );
+ mLeftCamera->SetOrientation( Dali::ANGLE_0, Vector3::ZAXIS );
mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
mLeftRenderTask.SetViewport( Viewport(0, 0, mSize.width * 0.5f, mSize.height ) );
mRightCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(-stereoBase,0.0f) );
mRightCamera->SetFieldOfView( fov );
- mRightCamera->SetOrientation( Degree(0.0f), Vector3::ZAXIS );
+ mRightCamera->SetOrientation( Dali::ANGLE_0, Vector3::ZAXIS );
mRightCamera->SetPosition( Vector3( -stereoBase, 0.0f, 0.0f ) );
mRightRenderTask.SetViewport( Viewport(mSize.width * 0.5f, 0, mSize.width * 0.5f, mSize.height ) );
#if defined(DEBUG_ENABLED)
Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_PAN_GESTURE_DETECTOR");
-
-/**
- * When debugging, helper for converting radians to degrees.
- */
-inline float RadiansToDegrees( float radian )
-{
- return radian * 180.0f / Math::PI;
-}
-
#endif
/**
angle = WrapInDomain( angle, -Math::PI, Math::PI );
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Angle Added: %.2f, Threshold: %.2f\n", RadiansToDegrees(angle), RadiansToDegrees(threshold) );
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Angle Added: %.2f, Threshold: %.2f\n", Degree(angle), Degree(threshold) );
AngleThresholdPair pair( angle, threshold );
mAngleContainer.push_back( pair );
DALI_LOG_INFO( gLogFilter, Debug::General,
"AngleToCheck: %.2f, CompareWith: %.2f, Threshold: %.2f\n",
- RadiansToDegrees(angle), RadiansToDegrees(angleAllowed), RadiansToDegrees(threshold) );
+ Degree(angle.radian), Degree(angleAllowed), Degree(threshold) );
float relativeAngle( fabsf( WrapInDomain( angle - angleAllowed, -Math::PI, Math::PI ) ) );
if ( relativeAngle <= threshold )
if ( displacement.y >= 0.0f )
{
// Quadrant 2
- angle += Math::PI;
+ angle.radian += Math::PI;
}
else
{
// Quadrant 3
- angle -= Math::PI;
+ angle.radian -= Math::PI;
}
}
struct RotateByAngleAxis : public AnimatorFunctionBase
{
RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
- : mAngleRadians(angleRadians),
- mAxis(axis.x, axis.y, axis.z, 0.0f)
+ : mAngleRadians( angleRadians ),
+ mAxis(axis.x, axis.y, axis.z)
{
}
return rotation;
}
- float mAngleRadians;
- Vector4 mAxis;
+ Radian mAngleRadians;
+ Vector3 mAxis;
};
struct RotateToQuaternion : public AnimatorFunctionBase
const Vector3& fullPos = node.GetWorldPosition(updateBufferIndex);
const Quaternion& rotation = node.GetOrientation(updateBufferIndex);
Vector3 axis;
- float angle;
+ Radian angle;
rotation.ToAxisAngle(axis, angle);
- angle = angle * 180.0f / Math::PI;
std::string nodeName= DALI_LOG_GET_OBJECT_STRING((&node));
oss << std::setprecision(2) << std::setiosflags(mask)
<< std::setw(level*2) << std::setfill(' ') << "";
oss << "Node " << nodeName << " " << &node
- << " Pos (" << position.x << ", " << position.y << ", " << position.z << ")"
- << " FullPos (" << fullPos.x << ", " << fullPos.y << ", " << fullPos.z << ")"
- << " Rot (" << angle << "deg <" << axis.x << ", " << axis.y << ", " << axis.z << ">)"
+ << " Position (" << position.x << ", " << position.y << ", " << position.z << ")"
+ << " WorldPosition (" << fullPos.x << ", " << fullPos.y << ", " << fullPos.z << ")"
+ << " Orientation (" << Degree(angle).degree << "degrees <" << axis.x << ", " << axis.y << ", " << axis.z << ">)"
<< " Scale (" << scale.x << ", " << scale.y << ", " << scale.z << ")"
<< std::endl;
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/math/degree.h>
#include <dali/public-api/math/radian.h>
#include <dali/public-api/math/vector2.h>
return GetImplementation(*this).GetPositionInheritanceMode();
}
-void Actor::SetOrientation(const Degree& angle, const Vector3& axis)
-{
- GetImplementation(*this).SetOrientation(Radian(angle), axis);
-}
-
void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
{
GetImplementation(*this).SetOrientation(angle, axis);
GetImplementation(*this).SetOrientation(orientation);
}
-void Actor::RotateBy(const Degree& angle, const Vector3& axis)
-{
- GetImplementation(*this).RotateBy(Radian(angle), axis);
-}
-
void Actor::RotateBy(const Radian& angle, const Vector3& axis)
{
GetImplementation(*this).RotateBy(angle, axis);
#define __DALI_ACTOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/actors/actor-enumerations.h>
#include <dali/public-api/actors/draw-mode.h>
+#include <dali/public-api/math/radian.h>
#include <dali/public-api/object/handle.h>
#include <dali/public-api/object/property-index-ranges.h>
#include <dali/public-api/signals/dali-signal.h>
}
class Actor;
-class Animation;
-class Constraint;
struct Degree;
class Quaternion;
class Layer;
-struct Radian;
struct KeyEvent;
struct TouchEvent;
struct HoverEvent;
* @param [in] angle The new orientation angle in degrees.
* @param [in] axis The new axis of orientation.
*/
- void SetOrientation(const Degree& angle, const Vector3& axis);
+ void SetOrientation( const Degree& angle, const Vector3& axis )
+ {
+ SetOrientation( Radian( angle ), axis );
+ }
/**
* @brief Sets the orientation of the Actor.
* @param[in] angle The angle to the rotation to combine with the existing orientation.
* @param[in] axis The axis of the rotation to combine with the existing orientation.
*/
- void RotateBy(const Degree& angle, const Vector3& axis);
+ void RotateBy( const Degree& angle, const Vector3& axis )
+ {
+ RotateBy( Radian( angle ), axis );
+ }
/**
* @brief Apply a relative rotation to an actor.
// INTERNAL INCLUDES
#include <dali/public-api/animation/alpha-functions.h>
#include <dali/public-api/animation/time-period.h>
-#include <dali/public-api/math/quaternion.h>
-#include <dali/public-api/math/degree.h>
-#include <dali/public-api/math/radian.h>
-#include <dali/public-api/math/vector2.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/animation/animation-impl.h>
#include <dali/internal/event/effects/shader-effect-impl.h>
// INTERNAL INCLUDES
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/math/radian.h>
namespace Dali
{
DALI_IMPORT_API extern const float MACHINE_EPSILON_10000; ///< Epsilon for values near 10000
// float is preferred to double for performance on ARM targets
-static const float PI = static_cast<float>(M_PI); ///< Constant representing PI
-static const float PI_2 = static_cast<float>(M_PI_2); ///< Constant representing PI/2
-static const float PI_4 = static_cast<float>(M_PI_4); ///< Constant representing PI/4
+static const float PI = static_cast<float>(M_PI); ///< Constant representing PI
+static const float PI_2 = static_cast<float>(M_PI_2); ///< Constant representing PI/2
+static const float PI_4 = static_cast<float>(M_PI_4); ///< Constant representing PI/4
+static const float PI_OVER_180 = Dali::Math::PI/180.0f; ///< Constant used to convert degree to radian
+static const float ONE80_OVER_PI = 180.0f/Dali::Math::PI; ///< Constant used to convert radian to degree
} // namespace Math
$(public_api_src_dir)/images/nine-patch-image.cpp \
$(public_api_src_dir)/images/resource-image.cpp \
$(public_api_src_dir)/images/native-image.cpp \
- $(public_api_src_dir)/math/angle-axis.cpp \
$(public_api_src_dir)/math/compile-time-math.cpp \
$(public_api_src_dir)/math/degree.cpp \
$(public_api_src_dir)/math/matrix.cpp \
$(public_api_src_dir)/math/matrix3.cpp \
$(public_api_src_dir)/math/quaternion.cpp \
- $(public_api_src_dir)/math/radian.cpp \
$(public_api_src_dir)/math/vector2.cpp \
$(public_api_src_dir)/math/vector3.cpp \
$(public_api_src_dir)/math/vector4.cpp \
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/math/angle-axis.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/math/radian.h>
-
-namespace Dali
-{
-
-AngleAxis::AngleAxis()
-: angle(0.0f),
- axis(0.0f, 0.0f, 0.0f)
-{
-}
-
-AngleAxis::AngleAxis( Degree initialAngle, Vector3 initialAxis )
-: angle( initialAngle ),
- axis( initialAxis )
-{
-}
-
-AngleAxis::AngleAxis( Radian initialAngle, Vector3 initialAxis )
-: angle( initialAngle ),
- axis( initialAxis )
-{
-}
-
-
-} // namespace Dali
#define __DALI_ANGLE_AXIS_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
// INTERNAL INCLUDES
#include <dali/public-api/math/degree.h>
+#include <dali/public-api/math/radian.h>
#include <dali/public-api/math/vector3.h>
namespace Dali
* This is slightly easier to understand than quaternions for handling rotations
* of objects. Both elements should be non-zero to correctly describe a rotation.
*/
-struct DALI_IMPORT_API AngleAxis
+struct AngleAxis
{
/**
* @brief Create an angle-axis pair.
- *
*/
- AngleAxis();
+ AngleAxis()
+ : angle(0.0f),
+ axis(0.0f, 0.0f, 0.0f)
+ { }
/**
* @brief Create an angle-axis pair.
* @param[in] initialAngle The initial angle in degrees.
* @param[in] initialAxis The initial axis.
*/
- AngleAxis( Degree initialAngle, Vector3 initialAxis );
+ AngleAxis( Degree initialAngle, Vector3 initialAxis )
+ : angle( initialAngle ),
+ axis( initialAxis )
+ { }
/**
* @brief Create an angle-axis pair.
* @param[in] initialAngle The initial angle in radians.
* @param[in] initialAxis The initial axis.
*/
- AngleAxis( Radian initialAngle, Vector3 initialAxis );
+ AngleAxis( Radian initialAngle, Vector3 initialAxis )
+ : angle( initialAngle ),
+ axis( initialAxis )
+ { }
- Degree angle; ///< The angle in degrees
+ Radian angle; ///< The angle in radians
Vector3 axis; ///< The axis
+
};
+// compiler generated destructor, copy constructor and assignment operators are ok as this class is POD
+
} // namespace Dali
#endif // __DALI_ANGLE_AXIS_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
#include <dali/public-api/math/degree.h>
// INTERNAL INCLUDES
-#include <dali/public-api/math/math-utils.h>
#include <dali/public-api/math/radian.h>
-namespace
-{
-const float ONE80_OVER_PI = 180.0f/Dali::Math::PI;
-}
-
namespace Dali
{
-Degree::Degree( float value )
-: mValue( value )
-{
-}
-
-Degree::Degree( const Radian& radian )
-: mValue( radian * ONE80_OVER_PI )
-{
-}
-
-bool Degree::operator==( const Degree& rhs ) const
-{
- return fabsf( mValue - rhs.mValue ) < GetRangedEpsilon( mValue, rhs.mValue );
-}
-
-bool Degree::operator!=( const Degree& rhs ) const
-{
- return !(this->operator==(rhs));
-}
-
-bool Degree::operator<( const Degree& rhs ) const
-{
- return mValue < rhs.mValue;
-}
-
-Degree& Degree::operator=( const float value )
-{
- mValue = value;
- return *this;
-}
-
-Degree& Degree::operator=( const Radian& rhs )
-{
- mValue = rhs * ONE80_OVER_PI;
- return *this;
-}
-
-Degree::operator const float&() const
-{
- return mValue;
-}
-
-Degree::operator float&()
+Degree::Degree( Radian radian )
+: degree( radian * Math::ONE80_OVER_PI )
{
- return mValue;
}
} // namespace Dali
#define __DALI_DEGREE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
*
*/
+// EXTERNAL INCLUDES
+#include <ostream>
+
// INTERNAL INCLUDES
+#include <dali/public-api/common/constants.h>
#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/math/math-utils.h>
namespace Dali
{
*
* This reduces ambiguity when using methods which accept angles in degrees or radians.
*/
-struct DALI_IMPORT_API Degree
+struct Degree
{
/**
- * @brief Create an angle in degrees.
- *
- * @param[in] value The initial value in degrees.
+ * @brief default constructor, initialises to 0.
*/
- explicit Degree( float value );
+ Degree()
+ : degree( 0.f )
+ { }
/**
- * @brief Create an angle in degrees from an angle in radians.
+ * @brief Create an angle in degrees.
*
- * @param[in] value The initial value in radians.
+ * @param[in] value The initial value in degrees.
*/
- Degree( const Radian& value );
+ explicit Degree( float value )
+ : degree( value )
+ { }
/**
- * @brief Compare equality between two degrees.
+ * @brief Create an angle in degrees from a Radian.
*
- * @param[in] rhs Degree to compare to
- * @return true if the value is identical
+ * @param[in] value The initial value in Radians.
*/
- bool operator==( const Degree& rhs ) const;
+ DALI_EXPORT_API Degree( Radian value );
- /**
- * @brief Compare inequality between two degrees.
- *
- * @param[in] rhs Degree to compare to
- * @return true if the value is not identical
- */
- bool operator!=( const Degree& rhs ) const;
+public:
- /**
- * @brief Compare two degrees.
- *
- * @param[in] rhs Degree to compare to
- * @return true if this is less than the value
- */
- bool operator<( const Degree& rhs ) const;
+ // member data
+ float degree; ///< The value in degrees
- /**
- * @brief Assign an angle from a float value.
- *
- * @param[in] value Float value in degrees
- * @return a reference to this
- */
- Degree& operator=( const float value );
+};
- /**
- * @brief Assign an angle in radians to a Degree.
- *
- * @param[in] rhs Radian to get the value from
- * @return a reference to this
- */
- Degree& operator=( const Radian& rhs );
+// compiler generated destructor, copy constructor and assignment operators are ok as this class is POD
- /**
- * @brief Cast operator to const float reference
- */
- operator const float&() const;
+/**
+ * @brief Compare equality between two degrees.
+ *
+ * @param[in] lhs Degree to compare
+ * @param[in] rhs Degree to compare to
+ * @return true if the values are identical
+ */
+inline bool operator==( const Degree& lhs, const Degree& rhs )
+{
+ return fabsf( lhs.degree - rhs.degree ) < Math::MACHINE_EPSILON_1000; // expect degree angles to be between 0 and 1000
+}
- /**
- * @brief Cast operator to float reference.
- */
- operator float&();
+/**
+ * @brief Compare inequality between two degrees.
+ *
+ * @param[in] lhs Degree to compare
+ * @param[in] rhs Degree to compare to
+ * @return true if the values are not identical
+ */
+inline bool operator!=( const Degree& lhs, const Degree& rhs )
+{
+ return !( operator==( lhs, rhs ) );
+}
-private:
- // member data
- float mValue; ///< The value in degrees
+/**
+ * @brief Clamp a radian value
+ * @param angle to clamp
+ * @param min value
+ * @param max value
+ * @return the resulting radian
+ */
+inline Degree Clamp( Degree angle, float min, float max )
+{
+ return Degree( Clamp<float>( angle.degree, min, max ) );
+}
- /**
- * @brief Disable the default constructor.
- */
- Degree();
-};
+/**
+ * @brief Stream a degree value
+ * @param [in] ostream The output stream to use.
+ * @param [in] angle in Degree.
+ * @return The output stream.
+ */
+inline std::ostream& operator<<( std::ostream& ostream, Degree angle )
+{
+ ostream << angle.degree;
+ return ostream;
+}
} // namespace Dali
* 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)
+Quaternion::Quaternion( const Vector4& vector )
{
mVector = vector;
}
-Quaternion::Quaternion(float angle, const Vector3 &axis)
+Quaternion::Quaternion( Radian angle, const Vector3& axis )
{
MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,4);
Vector3 tmpAxis = axis;
tmpAxis.Normalize();
- const float halfAngle = angle * 0.5f;
+ const float halfAngle = angle.radian * 0.5f;
const float sinThetaByTwo = sinf(halfAngle);
const float cosThetaByTwo = cosf(halfAngle);
mVector.x = tmpAxis.x * sinThetaByTwo;
mVector.w = cosThetaByTwo;
}
-Quaternion::Quaternion(float theta, const Vector4 &axis)
+Quaternion::Quaternion( Radian pitch, Radian yaw, Radian roll )
{
- MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,4);
-
- Vector4 tmpAxis = axis;
- tmpAxis.Normalize();
- const float halfTheta = theta * 0.5f;
- const float sinThetaByTwo = sinf(halfTheta);
- const float cosThetaByTwo = cosf(halfTheta);
- mVector.x = tmpAxis.x * sinThetaByTwo;
- mVector.y = tmpAxis.y * sinThetaByTwo;
- mVector.z = tmpAxis.z * sinThetaByTwo;
- mVector.w = cosThetaByTwo;
-}
-
-Quaternion::Quaternion(float x, float y, float z)
-{
- SetEuler(x,y,z);
+ SetEuler( pitch, yaw, roll );
}
-Quaternion::Quaternion(const Matrix& matrix)
+Quaternion::Quaternion( const Matrix& matrix )
{
Vector3 xAxis( matrix.GetXAxis() );
Vector3 yAxis( matrix.GetYAxis() );
}
}
-Quaternion Quaternion::FromAxisAngle(const Vector4 &axis, float angle)
-{
- return Quaternion(angle, axis);
-}
-
Quaternion::~Quaternion()
{
}
( fabsf( mVector.z ) < Math::MACHINE_EPSILON_10 ) );
}
-bool Quaternion::ToAxisAngle(Vector3 &axis, float &angle) const
+bool Quaternion::ToAxisAngle(Vector3& axis, Radian& angle) const
{
angle = acosf(mVector.w);
bool converted = false;
// pre-compute to save time
- const float sine = sinf( angle );
+ const float sine = sinf( angle.radian );
// If sine(angle) is zero, conversion is not possible
axis.x = mVector.x*sinf_theta_inv;
axis.y = mVector.y*sinf_theta_inv;
axis.z = mVector.z*sinf_theta_inv;
- angle*=2.0f;
+ angle.radian *= 2.0f;
converted = true;
}
return converted;
}
-bool Quaternion::ToAxisAngle(Vector4 &axis, float &angle) const
-{
- Vector3 axis3;
- bool converted = ToAxisAngle(axis3, angle);
- if(converted)
- {
- axis.x = axis3.x;
- axis.y = axis3.y;
- axis.z = axis3.z;
- axis.w = 0;
- }
- return converted;
-}
-
const Vector4& Quaternion::AsVector() const
{
return mVector;
}
-void Quaternion::SetEuler(float x, float y, float z)
+void Quaternion::SetEuler( Radian pitch, Radian yaw, Radian roll )
{
MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,19);
- const float halfX = 0.5f * x;
- const float halfY = 0.5f * y;
- const float halfZ = 0.5f * z;
+ const float halfX = 0.5f * pitch.radian;
+ const float halfY = 0.5f * yaw.radian;
+ const float halfZ = 0.5f * roll.radian;
float cosX2 = cosf(halfX);
float cosY2 = cosf(halfY);
return euler;
}
-const Quaternion Quaternion::operator +(const Quaternion &other) const
+const Quaternion Quaternion::operator+( const Quaternion& other ) const
{
return Quaternion(mVector + other.mVector);
}
-const Quaternion Quaternion::operator -(const Quaternion &other) const
+const Quaternion Quaternion::operator-( const Quaternion& other ) const
{
return Quaternion(mVector - other.mVector);
}
-const Quaternion Quaternion::operator *(const Quaternion &other) const
+const Quaternion Quaternion::operator*( const Quaternion& other ) const
{
MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,12);
mVector.x * other.mVector.y - mVector.y * other.mVector.x + mVector.w * other.mVector.z + mVector.z * other.mVector.w);
}
-Vector3 Quaternion::operator *(const Vector3& v) const
+Vector3 Quaternion::operator*( const Vector3& other ) const
{
- // nVidia SDK implementation
- Vector3 uv, uuv;
Vector3 qvec(mVector.x, mVector.y, mVector.z);
- uv = qvec.Cross(v);
- uuv = qvec.Cross(uv);
+ Vector3 uv = qvec.Cross( other );
+ Vector3 uuv = qvec.Cross(uv);
uv *= (2.0f * mVector.w);
uuv *= 2.0f;
- return v + uv + uuv;
+ return other + uv + uuv;
}
-const Quaternion Quaternion::operator /(const Quaternion &q) const
+const Quaternion Quaternion::operator/( const Quaternion& q ) const
{
Quaternion p(q);
p.Invert();
return *this * p;
}
-const Quaternion Quaternion::operator *(float scale) const
+const Quaternion Quaternion::operator*( float scale ) const
{
return Quaternion(mVector*scale);
}
-const Quaternion Quaternion::operator /(float scale) const
+const Quaternion Quaternion::operator/( float scale ) const
{
return Quaternion(mVector/scale);
}
-Quaternion Quaternion::operator -() const
+Quaternion Quaternion::operator-() const
{
return Quaternion(-mVector.w, -mVector.x, -mVector.y, -mVector.z);
}
-const Quaternion& Quaternion::operator +=(const Quaternion &q)
+const Quaternion& Quaternion::operator+=( const Quaternion& q )
{
mVector += q.mVector; return *this;
}
-const Quaternion& Quaternion::operator -=(const Quaternion &q)
+const Quaternion& Quaternion::operator-=( const Quaternion& q )
{
mVector -= q.mVector; return *this;
}
-const Quaternion& Quaternion::operator *=(const Quaternion &q)
+const Quaternion& Quaternion::operator*=( const Quaternion& q )
{
MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,12);
return *this;
}
-const Quaternion& Quaternion::operator *= (float scale)
+const Quaternion& Quaternion::operator*=( float scale )
{
mVector*=scale; return *this;
}
-const Quaternion& Quaternion::operator /= (float scale)
+const Quaternion& Quaternion::operator/=( float scale )
{
mVector/=scale; return *this;
}
-bool Quaternion::operator== (const Quaternion& rhs) const
+bool Quaternion::operator==( const Quaternion& rhs ) const
{
return ( ( fabsf(mVector.x - rhs.mVector.x) < Math::MACHINE_EPSILON_1 &&
fabsf(mVector.y - rhs.mVector.y) < Math::MACHINE_EPSILON_1 &&
);
}
-bool Quaternion::operator!= (const Quaternion& rhs) const
+bool Quaternion::operator!=( const Quaternion& rhs ) const
{
return !operator==(rhs);
}
return ret;
}
-float Quaternion::Dot(const Quaternion &q1, const Quaternion &q2)
+float Quaternion::Dot( const Quaternion& q1, const Quaternion& q2 )
{
return q1.mVector.Dot4(q2.mVector);
}
-Quaternion Quaternion::Lerp(const Quaternion &q1, const Quaternion &q2, float t)
+Quaternion Quaternion::Lerp(const Quaternion& q1, const Quaternion& q2, float t )
{
return (q1*(1.0f-t) + q2*t).Normalized();
}
-Quaternion Quaternion::Slerp(const Quaternion &q1, const Quaternion &q2, float progress)
+Quaternion Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float progress )
{
Quaternion q3;
float cosTheta = Quaternion::Dot(q1, q2);
}
}
-Quaternion Quaternion::SlerpNoInvert(const Quaternion &q1, const Quaternion &q2, float t)
+Quaternion Quaternion::SlerpNoInvert( const Quaternion& q1, const Quaternion& q2, float t )
{
float cosTheta = Quaternion::Dot(q1, q2);
}
}
-Quaternion Quaternion::Squad(
- const Quaternion &q1, // start
- const Quaternion &q2, // end
- const Quaternion &a, // ctrl pt for q1
- const Quaternion &b, // ctrl pt for q2
- float t)
+Quaternion Quaternion::Squad( const Quaternion& start, const Quaternion& end, const Quaternion& ctrl1, const Quaternion& ctrl2, float t )
{
MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,2);
- Quaternion c = SlerpNoInvert(q1, q2, t);
- Quaternion d = SlerpNoInvert(a, b, t);
- return SlerpNoInvert(c, d, 2*t*(1-t));
+ Quaternion c = SlerpNoInvert( start, end, t );
+ Quaternion d = SlerpNoInvert( ctrl1, ctrl2, t );
+ return SlerpNoInvert( c, d, 2*t*(1-t) );
}
-float Quaternion::AngleBetween(const Quaternion &q1, const Quaternion &q2)
+float Quaternion::AngleBetween( const Quaternion& q1, const Quaternion& q2 )
{
Quaternion from(q1);
Quaternion to(q2);
return theta;
}
-Vector4 Quaternion::Rotate(const Vector4 &v) const
+Vector4 Quaternion::Rotate( const Vector4& vector ) const
{
- Quaternion V(0.0f, v.x, v.y, v.z);
+ Quaternion V(0.0f, vector.x, vector.y, vector.z);
Quaternion conjugate(*this);
conjugate.Conjugate();
return (*this * V * conjugate).mVector;
}
-Vector3 Quaternion::Rotate(const Vector3 &v) const
+Vector3 Quaternion::Rotate( const Vector3& vector ) const
{
- Quaternion V(0.0f, v.x, v.y, v.z);
+ Quaternion V(0.0f, vector.x, vector.y, vector.z);
Quaternion conjugate(*this);
conjugate.Conjugate();
return Vector3((*this * V * conjugate).mVector);
Normalize();
}
-std::ostream& operator<< (std::ostream& o, const Quaternion& quaternion)
+std::ostream& operator<<( std::ostream& o, const Quaternion& quaternion )
{
Vector3 axis;
- float angleRadians;
+ Radian angleRadians;
quaternion.ToAxisAngle( axis, angleRadians );
- Degree degrees = Radian(angleRadians);
+ Degree degrees = Radian( angleRadians );
- return o << "[ Axis: [" << axis.x << ", " << axis.y << ", " << axis.z << "], Angle: " << degrees << " degrees ]";
+ return o << "[ Axis: [" << axis.x << ", " << axis.y << ", " << axis.z << "], Angle: " << degrees.degree << " degrees ]";
}
} // namespace Dali
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/common/constants.h>
+#include <dali/public-api/math/radian.h>
#include <dali/public-api/math/vector4.h>
namespace Dali
* @param[in] jBySineTheta
* @param[in] kBySineTheta
*/
- Quaternion(float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta);
+ Quaternion( float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta );
/**
* @brief Construct from a quaternion represented by a vector.
*
* @param[in] vector - x,y,z fields represent i,j,k coefficients, w represents cos(theta/2)
*/
- explicit Quaternion(const Vector4& vector);
+ explicit Quaternion( const Vector4& vector );
/**
* @brief Constructor from an axis and angle.
* @param[in] angle - the angle around the axis
* @param[in] axis - the vector of the axis
*/
- Quaternion(float angle, const Vector3 &axis);
-
- /**
- * @brief Constructor from an axis and angle.
- *
- * @param[in] theta - the angle of the axis
- * @param[in] axis - the unit vector of the axis
- */
- Quaternion(float theta, const Vector4 &axis);
+ Quaternion( Radian angle, const Vector3& axis );
/**
* @brief Construct from Euler angles.
*
- * @param[in] x - the X axis euler angle (pitch)
- * @param[in] y - the Y axis euler angle (yaw)
- * @param[in] z - the Z axis euler angle (roll)
+ * @param[in] pitch
+ * @param[in] yaw
+ * @param[in] roll
*/
- Quaternion(float x, float y, float z);
+ Quaternion( Radian pitch, Radian yaw, Radian roll );
/**
* @brief Construct from a matrix.
explicit Quaternion( const Vector3& v0, const Vector3& v1 );
/**
- * @brief Converts an axis + angle pair rotation to a Quaternion.
- *
- * @param[in] axis
- * @param[in] angle
- * @return the represented quaternion
- */
- static Quaternion FromAxisAngle(const Vector4 &axis, float angle);
-
- /**
* @brief Destructor, nonvirtual as this is not a base class.
*
*/
* @brief Convert the quaternion to an axis/angle pair.
*
* @param[out] axis
- * @param[out] angle
+ * @param[out] angle in radians
* @return true if converted correctly
*/
- bool ToAxisAngle(Vector3 &axis, float &angle) const;
-
- /**
- * @brief Convert the quaternion to an axis/angle pair.
- *
- * @param[out] axis
- * @param[out] angle
- * @return true if converted correctly
- */
- bool ToAxisAngle(Vector4 &axis, float &angle) const;
+ bool ToAxisAngle( Vector3& axis, Radian& angle ) const;
/**
* @brief Return the quaternion as a vector.
/**
* @brief SetEuler sets the quaternion from the Euler angles applied in x, y, z order.
*
- * @param[in] x - the X axis euler angle (pitch)
- * @param[in] y - the Y axis euler angle (yaw)
- * @param[in] z - the Z axis euler angle (roll)
+ * @param[in] pitch
+ * @param[in] yaw
+ * @param[in] roll
*/
- void SetEuler(float x, float y, float z);
+ void SetEuler( Radian pitch, Radian yaw, Radian roll );
/**
* @brief returns the Euler angles from a rotation Quaternion.
* @param[in] other The quaternion to add
* @return A quaternion containing the result of the addition
*/
- const Quaternion operator +(const Quaternion &other) const;
+ const Quaternion operator+( const Quaternion& other ) const;
/**
* @brief Subtraction operator.
* @param[in] other The quaternion to subtract
* @return A quaternion containing the result of the subtract
*/
- const Quaternion operator -(const Quaternion &other) const;
+ const Quaternion operator-( const Quaternion& other ) const;
/**
* @brief Multiplication operator.
* @param[in] other The quaternion to multiply
* @return A quaternion containing the result
*/
- const Quaternion operator *(const Quaternion &other) const;
+ const Quaternion operator*( const Quaternion& other ) const;
/**
* @brief Multiplication operator.
*
- * @param[in] v The vector to multiply
+ * @param[in] other The vector to multiply
* @return A vector containing the result of the multiplication
*/
- Vector3 operator *(const Vector3& v) const;
+ Vector3 operator*( const Vector3& other ) const;
/**
* @brief Division operator.
* @param[in] other a quaternion to divide by
* @return A quaternion containing the result
*/
- const Quaternion operator /(const Quaternion &other) const;
+ const Quaternion operator/( const Quaternion& other ) const;
/**
* @brief Scale operator.
* @param[in] scale A value to scale by
* @return A quaternion containing the result
*/
- const Quaternion operator *(float scale) const;
+ const Quaternion operator*( float scale ) const;
/**
* @brief Scale operator.
* @param[in] scale A value to scale by
* @return A quaternion containing the result
*/
- const Quaternion operator /(float scale) const;
+ const Quaternion operator/( float scale ) const;
/**
* @brief Unary Negation operator.
*
* @return A quaternion containing the negated result
*/
- Quaternion operator -() const;
+ Quaternion operator-() const;
/**
* @brief Addition with Assignment operator.
* @param[in] other The quaternion to add
* @return itself
*/
- const Quaternion &operator +=(const Quaternion &other);
+ const Quaternion& operator+=( const Quaternion& other );
/**
* @brief Subtraction with Assignment operator.
* @param[in] other The quaternion to subtract
* @return itself
*/
- const Quaternion &operator -=(const Quaternion &other);
+ const Quaternion& operator-=( const Quaternion& other );
/**
* @brief Multiplication with Assignment operator.
* @param[in] other The quaternion to multiply
* @return itself
*/
- const Quaternion &operator *=(const Quaternion &other);
+ const Quaternion& operator*=( const Quaternion& other );
/**
* @brief Scale with Assignment operator.
* @param[in] scale the value to scale by
* @return itself
*/
- const Quaternion &operator *= (float scale);
+ const Quaternion& operator*=( float scale );
/**
* @brief Scale with Assignment operator.
* @param[in] scale the value to scale by
* @return itself
*/
- const Quaternion &operator /= (float scale);
+ const Quaternion& operator/=( float scale );
/**
* @brief Equality operator.
* @param[in] rhs The quaterion to compare with.
* @return True if the quaternions are equal.
*/
- bool operator== (const Quaternion& rhs) const;
+ bool operator==( const Quaternion& rhs ) const;
/**
* @brief Inequality operator.
* @param[in] rhs The quaterion to compare with.
* @return True if the quaternions are not equal.
*/
- bool operator!= (const Quaternion& rhs) const;
+ bool operator!=( const Quaternion& rhs ) const;
/**
* @brief Return the length of the quaternion.
* @param[in] q2 - the second quaternion
* @return the dot product of the two quaternions
*/
- static float Dot(const Quaternion &q1, const Quaternion &q2);
+ static float Dot( const Quaternion &q1, const Quaternion &q2 );
/**
* @brief Linear Interpolation (using a straight line between the two quaternions).
* @param[in] t - a progress value between 0 and 1
* @return the interpolated quaternion
*/
- static Quaternion Lerp(const Quaternion &q1, const Quaternion &q2, float t);
+ static Quaternion Lerp( const Quaternion &q1, const Quaternion &q2, float t );
/**
* @brief Spherical Linear Interpolation (using the shortest arc of a great circle between
* @param[in] progress - a progress value between 0 and 1
* @return the interpolated quaternion
*/
- static Quaternion Slerp(const Quaternion &q1, const Quaternion &q2, float progress);
+ static Quaternion Slerp( const Quaternion &q1, const Quaternion &q2, float progress );
/**
* @brief This version of Slerp, used by Squad, does not check for theta > 90.
* @param[in] t - a progress value between 0 and 1
* @return the interpolated quaternion
*/
- static Quaternion SlerpNoInvert(const Quaternion &q1, const Quaternion &q2, float t);
+ static Quaternion SlerpNoInvert( const Quaternion &q1, const Quaternion &q2, float t );
/**
* @brief Spherical Cubic Interpolation.
*
- * @param[in] q1 - the start quaternion
- * @param[in] q2 - the end quaternion
- * @param[in] a - the control quaternion for q1
- * @param[in] b - the control quaternion for q2
+ * @param[in] start - the start quaternion
+ * @param[in] end - the end quaternion
+ * @param[in] ctrl1 - the control quaternion for q1
+ * @param[in] ctrl2 - the control quaternion for q2
* @param[in] t - a progress value between 0 and 1
* @return the interpolated quaternion
*/
- static Quaternion Squad(const Quaternion &q1,const Quaternion &q2,const Quaternion &a,const Quaternion &b,float t);
+ static Quaternion Squad( const Quaternion& start, const Quaternion& end, const Quaternion& ctrl1, const Quaternion& ctrl2, float t );
/**
* @brief Returns the shortest angle between two quaternions in Radians.
* @param[in] q2 - the second quaternion
* @return the angle between the two quaternions.
*/
- static float AngleBetween(const Quaternion &q1, const Quaternion &q2);
+ static float AngleBetween( const Quaternion& q1, const Quaternion& q2 );
/**
* @brief Rotate v by this Quaternion (Quaternion must be unit).
*
- * @param[in] v - a vector to rotate
+ * @param[in] vector a vector to rotate
* @return the rotated vector
*/
- Vector4 Rotate(const Vector4 &v) const;
+ Vector4 Rotate( const Vector4& vector ) const;
/**
* @brief Rotate v by this Quaternion (Quaternion must be unit).
*
- * @param[in] v - a vector to rotate
+ * @param[in] vector a vector to rotate
* @return the rotated vector
*/
- Vector3 Rotate(const Vector3 &v) const;
+ Vector3 Rotate( const Vector3& vector ) const;
private:
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/math/radian.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/math/math-utils.h>
-#include <dali/public-api/math/degree.h>
-
-namespace
-{
-const float PI_OVER_180 = Dali::Math::PI/180.0f;
-}
-
-namespace Dali
-{
-
-Radian::Radian( float value )
-: mValue( value )
-{
-}
-
-Radian::Radian( const Degree& degree )
-: mValue( degree * PI_OVER_180 )
-{
-}
-
-bool Radian::operator==( const Radian& rhs ) const
-{
- return fabsf( mValue - rhs.mValue ) < GetRangedEpsilon( mValue, rhs.mValue );
-}
-
-bool Radian::operator!=( const Radian& rhs ) const
-{
- return !(this->operator==(rhs));
-}
-
-bool Radian::operator<( const Radian& rhs ) const
-{
- return mValue < rhs.mValue;
-}
-
-Radian& Radian::operator=( const float value )
-{
- mValue = value;
- return *this;
-}
-
-Radian& Radian::operator=( const Degree& rhs )
-{
- mValue = rhs * PI_OVER_180;
- return *this;
-}
-
-Radian::operator const float&() const
-{
- return mValue;
-}
-
-Radian::operator float&()
-{
- return mValue;
-}
-
-} // namespace Dali
#define __DALI_RADIAN_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
*
*/
+// EXTERNAL INCLUDES
+#include <ostream>
+
// INTERNAL INCLUDES
+#include <dali/public-api/common/constants.h>
#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/math/math-utils.h>
+#include <dali/public-api/math/degree.h>
namespace Dali
{
-struct Degree;
-
/**
* @brief An angle in radians.
*
* This reduces ambiguity when using methods which accept angles in degrees or radians.
*/
-struct DALI_IMPORT_API Radian
+struct Radian
{
/**
- * @brief Create an angle in radians.
- *
- * @param[in] value The initial value in radians.
+ * @brief default constructor, initialises to 0.
*/
- explicit Radian( float value );
+ Radian()
+ : radian( 0.f )
+ { }
/**
- * @brief Create an angle in radians from an angle in degrees.
- *
- * @param[in] value The initial value in degrees.
- */
- Radian( const Degree& value );
-
- /**
- * @brief Compare equality between two radians.
- *
- * @param[in] rhs Radian to compare to
- * @return true if the value is identical
- */
- bool operator==( const Radian& rhs ) const;
-
- /**
- * @brief Compare inequality between two radians.
+ * @brief Create an angle in radians.
*
- * @param[in] rhs Radian to compare to
- * @return true if the value is not identical
+ * @param[in] value The initial value in radians.
*/
- bool operator!=( const Radian& rhs ) const;
+ explicit Radian( float value )
+ : radian( value )
+ { }
/**
- * @brief Compare two radians.
+ * @brief Create an angle in radians from an angle in degrees.
*
- * @param[in] rhs Radian to compare to
- * @return true if this is less than the value
+ * @param[in] degree The initial value in degrees.
*/
- bool operator<( const Radian& rhs ) const;
+ Radian( Degree degree )
+ : radian( degree.degree * Math::PI_OVER_180 )
+ { }
/**
* @brief Assign an angle from a float value.
* @param[in] value Float value in radians
* @return a reference to this object
*/
- Radian& operator=( const float value );
+ Radian& operator=( float value )
+ {
+ radian = value;
+ return *this;
+ }
/**
- * @brief Assign an angle in degrees to a Radian.
+ * @brief Assign an angle from a Degree value.
*
- * @param[in] rhs Degree to get the value from
+ * @param[in] degree The value in degrees.
* @return a reference to this object
*/
- Radian& operator=( const Degree& rhs );
+ Radian& operator=( Degree degree )
+ {
+ radian = degree.degree * Math::PI_OVER_180;
+ return *this;
+ }
/**
- * @brief Cast operator to const float reference.
+ * @brief Conversion to float
+ * @return the float value of this Radian
*/
- operator const float&() const;
+ operator float() const
+ {
+ return radian;
+ }
- /**
- * @brief Cast operator to float reference.
- */
- operator float&();
+public:
-private:
// member data
- float mValue; ///< The value in radians
+ float radian; ///< The value in radians
- // disable default constructor
- Radian();
};
+// compiler generated destructor, copy constructor and assignment operators are ok as this class is POD
+
+// useful constant angles
+static const Radian ANGLE_360 = Radian( Math::PI * 2.00f ); ///< 360 degree turn in radians
+static const Radian ANGLE_315 = Radian( Math::PI * 1.75f ); ///< 315 degree turn in radians
+static const Radian ANGLE_270 = Radian( Math::PI * 1.50f );///< 270 degree turn in radians
+static const Radian ANGLE_225 = Radian( Math::PI * 1.25f ); ///< 225 degree turn in radians
+static const Radian ANGLE_180 = Radian( Math::PI ); ///< 180 degree turn in radians
+static const Radian ANGLE_135 = Radian( Math::PI * 0.75f ); ///< 135 degree turn in radians
+static const Radian ANGLE_120 = Radian( Math::PI / 3.00f ); ///< 120 degree turn in radians
+static const Radian ANGLE_90 = Radian( Math::PI_2 ); ///< 90 degree turn in radians
+static const Radian ANGLE_45 = Radian( Math::PI_4 ); ///< 45 degree turn in radians
+static const Radian ANGLE_30 = Radian( Math::PI / 6.00f ); ///< 30 degree turn in radians
+static const Radian ANGLE_0 = Radian( 0.0f ); ///< 0 degree turn in radians
+
+/**
+ * @brief Compare equality between two radians.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Radian to compare to
+ * @return true if the values are identical
+ */
+inline bool operator==( Radian lhs, Radian rhs )
+{
+ return fabsf( lhs.radian - rhs.radian ) < Math::MACHINE_EPSILON_10; // expect Radian angles to be between 0 and 10 (multiplies of Math::PI)
+}
+
+/**
+ * @brief Compare inequality between two radians.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Radian to compare to
+ * @return true if the values are not identical
+ */
+inline bool operator!=( Radian lhs, Radian rhs )
+{
+ return !( operator==( lhs, rhs ) );
+}
+
+/**
+ * @brief Compare equality between a radian and degree.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Degree to compare to
+ * @return true if the values are identical
+ */
+inline bool operator==( Radian lhs, Degree rhs )
+{
+ return fabsf( lhs.radian - Radian( rhs ).radian ) < Math::MACHINE_EPSILON_100; // expect Degree angles to be between 0 and 999
+}
+
+/**
+ * @brief Compare inequality between a radian and a degree.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Degree to compare to
+ * @return true if the values are not identical
+ */
+inline bool operator!=( Radian lhs, Degree rhs )
+{
+ return !( operator==( lhs, rhs ) );
+}
+
+/**
+ * @brief Compare equality between a degree and a radian.
+ *
+ * @param[in] lhs Degree to compare
+ * @param[in] rhs Radian to compare to
+ * @return true if the values are identical
+ */
+inline bool operator==( Degree lhs, Radian rhs )
+{
+ return fabsf( Radian( lhs ).radian - rhs.radian ) < Math::MACHINE_EPSILON_100; // expect Degree angles to be between 0 and 999
+}
+
+/**
+ * @brief Compare inequality between a degree and a radian.
+ *
+ * @param[in] lhs Degree to compare
+ * @param[in] rhs Radian to compare to
+ * @return true if the values are not identical
+ */
+inline bool operator!=( Degree lhs, Radian rhs )
+{
+ return !( operator==( lhs, rhs ) );
+}
+
+/**
+ * @brief Compare greater than between two radians
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Radian to compare to
+ * @return true if lhs is greater than rhs
+ */
+inline bool operator>( Radian lhs, Radian rhs )
+{
+ return lhs.radian > rhs.radian;
+}
+
+/**
+ * @brief Compare greater than between a radian and a degree.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Degree to compare to
+ * @return true if lhs is greater than rhs
+ */
+inline bool operator>( Radian lhs, Degree rhs )
+{
+ return lhs.radian > Radian(rhs).radian;
+}
+
+/**
+ * @brief Compare greater than between a radian and a degree.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Degree to compare to
+ * @return true if lhs is greater than rhs
+ */
+inline bool operator>( Degree lhs, Radian rhs )
+{
+ return Radian(lhs).radian > rhs.radian;
+}
+
+/**
+ * @brief Compare less than between two radians.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Radian to compare to
+ * @return true if lhs is less than rhs
+ */
+inline bool operator<( Radian lhs, Radian rhs )
+{
+ return lhs.radian < rhs.radian;
+}
+
+/**
+ * @brief Compare less than between a radian and a degree.
+ *
+ * @param[in] lhs Radian to compare
+ * @param[in] rhs Degree to compare to
+ * @return true if lhs is less than rhs
+ */
+inline bool operator<( Radian lhs, Degree rhs )
+{
+ return lhs.radian < Radian(rhs).radian;
+}
+
+/**
+ * @brief Compare less than between a degree and a radian.
+ *
+ * @param[in] lhs Degree to compare
+ * @param[in] rhs Radian to compare to
+ * @return true if lhs is less than rhs
+ */
+inline bool operator<( Degree lhs, Radian rhs )
+{
+ return Radian(lhs).radian < rhs.radian;
+}
+
+/**
+ * @brief Multiply Radian with a float
+ *
+ * @param[in] lhs Radian to multiply
+ * @param[in] rhs float to multiply
+ * @return result of the multiplication
+ */
+inline Radian operator*( Radian lhs, float rhs )
+{
+ return Radian( lhs.radian * rhs );
+}
+
+/**
+ * @brief Negate the radian
+ * @return The negative angle
+ */
+inline Radian operator-( Radian in )
+{
+ return Radian( -in.radian );
+}
+
+/**
+ * @brief Clamp a radian value
+ * @param angle to clamp
+ * @param min value
+ * @param max value
+ * @return the resulting radian
+ */
+inline Radian Clamp( Radian angle, float min, float max )
+{
+ return Radian( Clamp<float>( angle.radian, min, max ) );
+}
+
+/**
+ * @brief Stream a radian value
+ * @param [in] ostream The output stream to use.
+ * @param [in] angle in Radian.
+ * @return The output stream.
+ */
+inline std::ostream& operator<<( std::ostream& ostream, Radian angle )
+{
+ ostream << angle.radian;
+ return ostream;
+}
+
} // namespace Dali
#endif // __DALI_RADIAN_H__
case Property::ROTATION:
{
- mImpl = new Impl( Quaternion(0.f, Vector4::YAXIS) );
+ mImpl = new Impl( Quaternion( Radian(0.f), Vector3::YAXIS) );
break;
}
{
Quaternion quaternion = AnyCast<Quaternion>(mImpl->mValue);
- Radian angleRadians(0.0f);
- quaternion.ToAxisAngle( angleAxisValue.axis, angleRadians );
- angleAxisValue.angle = angleRadians;
+ quaternion.ToAxisAngle( angleAxisValue.axis, angleAxisValue.angle );
}
else
{