namespace Syntriax.Engine.Core; /// /// Provides extension methods for type. /// public static class Vector2DExtensions { /// /// Calculates the length of the . /// /// The input . /// The length of the . public static float Length(this Vector2D vector) => Vector2D.Length(vector); /// /// Calculates the squared length of the . /// /// The input . /// The squared length of the . public static float LengthSquared(this Vector2D vector) => Vector2D.LengthSquared(vector); /// /// Calculates the distance between two s. /// /// The starting . /// The ending . /// The distance between the two s. public static float Distance(this Vector2D from, Vector2D to) => Vector2D.Distance(from, to); /// /// Returns the with its components inverted. /// /// The input . /// The inverted . public static Vector2D Invert(this Vector2D vector) => Vector2D.Invert(vector); /// /// Adds two s component-wise. /// /// The first . /// The vector to be added. /// The result of the addition. public static Vector2D Add(this Vector2D vector, Vector2D vectorToAdd) => Vector2D.Add(vector, vectorToAdd); /// /// Subtracts one from another component-wise. /// /// The first . /// The to be subtracted. /// The result of the subtraction. public static Vector2D Subtract(this Vector2D vector, Vector2D vectorToSubtract) => Vector2D.Subtract(vector, vectorToSubtract); /// /// Multiplies a by a scalar value. /// /// The to multiply. /// The scalar value to multiply with. /// The result of the multiplication. public static Vector2D Multiply(this Vector2D vector, float value) => Vector2D.Multiply(vector, value); /// /// Divides a by a scalar value. /// /// The to divide. /// The scalar value to divide with. /// The result of the division. public static Vector2D Divide(this Vector2D vector, float value) => Vector2D.Divide(vector, value); /// /// Returns a with the absolute values of each component. /// /// The input . /// The with absolute values. public static Vector2D Abs(this Vector2D vector) => Vector2D.Abs(vector); /// /// Reflects a off a surface with the specified normal. /// /// The to reflect. /// The normal of the reflecting surface. /// The reflected . public static Vector2D Reflect(this Vector2D vector, Vector2D normal) => Vector2D.Reflect(vector, normal); /// /// Normalizes the (creates a with the same direction but with a length of 1). /// /// The input . /// The normalized . public static Vector2D Normalize(this Vector2D vector) => Vector2D.Normalize(vector); /// /// Creates a pointing from one point to another. /// /// The starting point. /// The ending point. /// The pointing from to . public static Vector2D FromTo(this Vector2D from, Vector2D to) => Vector2D.FromTo(from, to); /// /// Scales a by another component-wise. /// /// The to scale. /// The containing the scaling factors for each component. /// The scaled . public static Vector2D Scale(this Vector2D vector, Vector2D scale) => Vector2D.Scale(vector, scale); /// /// Calculates the perpendicular to the given . /// /// The input . /// A perpendicular to the input . public static Vector2D Perpendicular(this Vector2D vector) => Vector2D.Perpendicular(vector); /// /// Rotates a by the specified angle (in radians). /// /// The to rotate. /// The angle to rotate by, in radians. /// The rotated . public static Vector2D Rotate(this Vector2D vector, float angleInRadian) => Vector2D.Rotate(vector, angleInRadian); /// /// Returns the component-wise minimum of two s. /// /// The first . /// The second . /// The containing the minimum components from both input s. public static Vector2D Min(this Vector2D left, Vector2D right) => Vector2D.Min(left, right); /// /// Returns the component-wise maximum of two s. /// /// The first . /// The second . /// The containing the maximum components from both input s. public static Vector2D Max(this Vector2D left, Vector2D right) => Vector2D.Max(left, right); /// /// Clamps each component of a between the corresponding component of two other s. /// /// The to clamp. /// The representing the minimum values for each component. /// The representing the maximum values for each component. /// The clamped . public static Vector2D Clamp(this Vector2D vector, Vector2D min, Vector2D max) => Vector2D.Clamp(vector, min, max); /// /// Linearly interpolates between two s. /// /// The start . /// The end . /// The interpolation parameter (between 0 and 1). /// The interpolated . public static Vector2D Lerp(this Vector2D from, Vector2D to, float t) => Vector2D.Lerp(from, to, t); /// /// Calculates the cross product of two s. /// /// The first . /// The second . /// The cross product of the two s. public static float Cross(this Vector2D left, Vector2D right) => Vector2D.Cross(left, right); /// /// Calculates the angle in radians between two s. /// /// The first . /// The second . /// The angle between the two s in radians. public static float AngleBetween(this Vector2D left, Vector2D right) => Vector2D.Angle(left, right); /// /// Calculates the dot product of two s. /// /// The first . /// The second . /// The dot product of the two s. public static float Dot(this Vector2D left, Vector2D right) => Vector2D.Dot(left, right); /// /// Checks whether two s are approximately equal within a certain epsilon range. /// /// The first . /// The second . /// The maximum difference allowed between components. /// True if the s are approximately equal, false otherwise. public static bool ApproximatelyEquals(this Vector2D left, Vector2D right, float epsilon = float.Epsilon) => Vector2D.ApproximatelyEquals(left, right, epsilon); }