Browse Source

Adds the clamped lerp to AGE

raheelx 9 years ago
parent
commit
e064f6578e
1 changed files with 10 additions and 0 deletions
  1. 10 0
      Source/Atomic/Math/Vector3.h

+ 10 - 0
Source/Atomic/Math/Vector3.h

@@ -222,6 +222,16 @@ public:
     /// Linear interpolation with another vector.
     /// Linear interpolation with another vector.
     Vector3 Lerp(const Vector3& rhs, float t) const { return *this * (1.0f - t) + rhs * t; }
     Vector3 Lerp(const Vector3& rhs, float t) const { return *this * (1.0f - t) + rhs * t; }
 
 
+    Vector3 ClampedLerp(const Vector3& rhs, float t) const 
+    {
+        if (t > 1)
+            t = 1;
+        else if (t < 0)
+            t = 0;
+
+        return *this * (1.0f - t) + rhs * t;
+    }
+
     /// Test for equality with another vector with epsilon.
     /// Test for equality with another vector with epsilon.
     bool Equals(const Vector3& rhs) const
     bool Equals(const Vector3& rhs) const
     {
     {