public static Vector4F Normalize(Vector4F a) { var num = Magnitude(a); if (num > 1E-05f) { return(a / num); } return(zero); }
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); }
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))); }
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))); }
public static float SqrMagnitude(Vector4F a) { return(Dot(a, a)); }
public static float Magnitude(Vector4F a) { return(Mathf.Sqrt(Dot(a, a))); }
public static float Distance(Vector4F a, Vector4F b) { return(Magnitude(a - b)); }
public static Vector4F Project(Vector4F a, Vector4F b) { return((b * Dot(a, b)) / Dot(b, b)); }
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)); }
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)); }