/// <summary> /// Calculates the dot product between the two vectors. /// </summary> /// <param name="v1">first vector</param> /// <param name="v2">second vector</param> /// <returns>value indicating the dot product.</returns> public static Fix32 Dot(Vector2F v1, Vector2F v2) { return(v1.x * v2.x + v1.y * v2.y); }
/// <summary> /// Clamps the x and y components of the given vector inside the min and max components. /// </summary> /// <param name="value">the vector to clamp</param> /// <param name="min">min x and y</param> /// <param name="max">max x and y</param> /// <returns>clamped vector</returns> public static Vector2F Clamp(Vector2F value, Vector2F min, Vector2F max) { value.x = Fix32.Clamp(value.x, min.x, max.x); value.y = Fix32.Clamp(value.y, min.y, max.y); return(value); }
/// <summary> /// Returns the euclidean distance between two coordinates. /// Note: Heavier than DistanceSquared, because of the Sqrt call. /// </summary> /// <param name="v1">first position</param> /// <param name="v2">second position</param> /// <returns>distance between the points</returns> public static Fix32 Distance(Vector2F v1, Vector2F v2) { return(Fix32.Sqrt(DistanceSquared(v1, v2))); }
/// <summary> /// Returns a vector containing the absolute value of its components. /// </summary> public static Vector2F Abs(Vector2F v) { return(new Vector2F(Fix32.Abs(v.x), Fix32.Abs(v.y))); }