Example #1
0
        public static Vector4F Normalize(Vector4F a)
        {
            var num = Magnitude(a);

            if (num > 1E-05f)
            {
                return(a / num);
            }

            return(zero);
        }
Example #2
0
        public static Vector4F MoveTowards(Vector4F current, Vector4F target, float maxDistanceDelta)
        {
            var vector    = target - current;
            var magnitude = vector.magnitude;

            if ((magnitude > maxDistanceDelta) && (magnitude != 0f))
            {
                return(current + (vector / magnitude) * maxDistanceDelta);
            }

            return(target);
        }
Example #3
0
        public static Vector4F Lerp(Vector4F from, Vector4F to, float t)
        {
            t = Mathf.Clamp01(t);

            return(new Vector4F(from.x + ((to.x - from.x) * t), from.y + ((to.y - from.y) * t), from.z + ((to.z - from.z) * t), from.w + ((to.w - from.w) * t)));
        }
Example #4
0
 public static Vector4F Max(Vector4F lhs, Vector4F rhs)
 {
     return(new Vector4F(Math.Max(lhs.x, rhs.x), Math.Max(lhs.y, rhs.y), Math.Max(lhs.z, rhs.z), Math.Max(lhs.w, rhs.w)));
 }
Example #5
0
 public static float SqrMagnitude(Vector4F a)
 {
     return(Dot(a, a));
 }
Example #6
0
 public static float Magnitude(Vector4F a)
 {
     return(Mathf.Sqrt(Dot(a, a)));
 }
Example #7
0
 public static float Distance(Vector4F a, Vector4F b)
 {
     return(Magnitude(a - b));
 }
Example #8
0
 public static Vector4F Project(Vector4F a, Vector4F b)
 {
     return((b * Dot(a, b)) / Dot(b, b));
 }
Example #9
0
 public static float Dot(Vector4F a, Vector4F b)
 {
     return((((a.x * b.x) + (a.y * b.y)) + (a.z * b.z)) + (a.w * b.w));
 }
Example #10
0
 public static Vector4F Scale(Vector4F a, Vector4F b)
 {
     return(new Vector4F(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w));
 }