/// <summary> /// Project given vector onto a line /// </summary> /// <param name="left">First operand</param> /// <param name="right">Second operand</param> /// <returns>The closest point on the line</returns> public static void Snap(ref Vector2 left, ref Line2 right, out Vector2 result) { result = Line2.NearestPoint(right, left); }
/// <summary> /// Calculate the mirror projection of the given vector and line /// </summary> /// <param name="left">First operand</param> /// <param name="right">Second operand</param> /// <returns>The mirror projection of the input</returns> public static void Mirror(ref Vector2 left, ref Line2 right, out Vector2 result) { var nearest = Line2.NearestPoint(right, left); result = left + 2 * (nearest - left); }