Example #1
0
        public static aQuat Slerp(aQuat start, aQuat end, float percent)
        {
            var cos = aQuat.DotProduct(start, end);

            if (cos < 0.0f)
            {
                cos = -cos;
                end = -end;
            }
            if ((1.0f - cos) > Single.Epsilon)
            {
                var angle  = (float)SystemMath.Acos(cos);
                var vector = new aVec3(
                    (float)SystemMath.Sin(angle * (1.0f - percent)),
                    (float)SystemMath.Sin(angle * percent),
                    (float)SystemMath.Sin(angle)
                    );
                return(new aQuat(
                           (start.x * vector.x + end.x * vector.y) / vector.z,
                           (start.y * vector.x + end.y * vector.y) / vector.z,
                           (start.z * vector.x + end.z * vector.y) / vector.z,
                           (start.w * vector.x + end.w * vector.y) / vector.z
                           ));
            }
            return(aQuat.Lerp(start, end, percent));
        }
Example #2
0
 public static bool Approximately(aQuat first, aQuat second, float deviation)
 {
     return(aMath.Approximately(first.x, second.x, deviation) &&
            aMath.Approximately(first.y, second.y, deviation) &&
            aMath.Approximately(first.z, second.z, deviation) &&
            aMath.Approximately(first.w, second.w, deviation));
 }
Example #3
0
 public static aQuat Lerp(aQuat start, aQuat end, float percent)
 {
     return(new aQuat(
                aMath.Lerp(start.x, end.x, percent),
                aMath.Lerp(start.y, end.y, percent),
                aMath.Lerp(start.z, end.z, percent),
                aMath.Lerp(start.w, end.w, percent)
                ));
 }
Example #4
0
 public static aQuat Slerp(aQuat start, aQuat end, float percent)
 {
     var cos = aQuat.DotProduct(start, end);
     if (cos < 0.0f) {
         cos = -cos;
         end = -end;
     }
     if ((1.0f - cos) > Single.Epsilon) {
         var angle = (float)SystemMath.Acos(cos);
         var vector = new aVec3(
             (float)SystemMath.Sin(angle * (1.0f - percent)),
             (float)SystemMath.Sin(angle * percent),
             (float)SystemMath.Sin(angle)
         );
         return new aQuat(
             (start.x * vector.x + end.x * vector.y) / vector.z,
             (start.y * vector.x + end.y * vector.y) / vector.z,
             (start.z * vector.x + end.z * vector.y) / vector.z,
             (start.w * vector.x + end.w * vector.y) / vector.z
         );
     }
     return aQuat.Lerp(start, end, percent);
 }
Example #5
0
 public static aQuat Lerp(aQuat start, aQuat end, float percent)
 {
     return new aQuat(
         aMath.Lerp(start.x, end.x, percent),
         aMath.Lerp(start.y, end.y, percent),
         aMath.Lerp(start.z, end.z, percent),
         aMath.Lerp(start.w, end.w, percent)
     );
 }
Example #6
0
 public static float DotProduct(aQuat a, aQuat b)
 {
     return (a.x * b.x + a.y * b.y + a.z * b.z * a.w * b.w);
 }
Example #7
0
 public static bool Approximately(aQuat first, aQuat second, float deviation)
 {
     return (aMath.Approximately(first.x, second.x, deviation) &&
             aMath.Approximately(first.y, second.y, deviation) &&
             aMath.Approximately(first.z, second.z, deviation) &&
             aMath.Approximately(first.w, second.w, deviation));
 }
Example #8
0
 public static bool Approximately(aQuat first, aQuat second)
 {
     return Approximately(first, second, Single.Epsilon);
 }
Example #9
0
 public static float DotProduct(aQuat a, aQuat b)
 {
     return(a.x * b.x + a.y * b.y + a.z * b.z * a.w * b.w);
 }
Example #10
0
 public static bool Approximately(aQuat first, aQuat second)
 {
     return(Approximately(first, second, Single.Epsilon));
 }