/// <summary> /// Rotates the given Position and Orientation around the Pivot Point, changing the Position and Orientation /// </summary> /// <param name="fRotation">The Rotation in radians to apply to the object</param> /// <param name="sPivotPoint">The Point to rotate the object around</param> /// <param name="srPosition">The Position of the object to be modified</param> /// <param name="frOrientation">The Orientation (rotation) of the object to be modified</param> public static void RotatePositionAndOrientation(float fRotation, Vector2 sPivotPoint, ref Vector2 srPosition, ref float frOrientation) { // Rotate the Orientation about it's center to change its Orientation frOrientation = Orientation2D.Rotate(fRotation, frOrientation); // Rotate the Position around the specified Pivot Point srPosition = PivotPoint2D.RotatePosition(fRotation, sPivotPoint, srPosition); }
/// <summary> /// Returns the new Position after Rotating the given Position around the specified Pivot Point. /// <para>NOTE: The Pivot Point and Position's Z-values are ignored.</para> /// <para>This function is provided for convenience when using 3D Vectors in 2D coordinate systems.</para> /// </summary> /// <param name="fRotation">The Rotation in radians to rotate around the Pivot Point by</param> /// <param name="sPivotPoint">The Point to Rotate around. /// NOTE: The Z-value is ignored, since this is a 2D rotation.</param> /// <param name="sPosition">The current Position of the object. /// NOTE: The Z-value is ignored and will not be changed, since this is a 2D rotation.</param> /// <returns>Returns the new Position after Rotating the given Position around the specified Pivot Point.</returns> public static Vector3 RotatePositionVector3(float fRotation, Vector3 sPivotPoint, Vector3 sPosition) { // Call the 2D function to perform the operations Vector2 cNewPosition = PivotPoint2D.RotatePosition(fRotation, new Vector2(sPivotPoint.X, sPivotPoint.Y), new Vector2(sPosition.X, sPosition.Y)); // Return the Rotated Position (with the original Z-value) return(new Vector3(cNewPosition.X, cNewPosition.Y, sPosition.Z)); }
/// <summary> /// Rotates the object around the specified Pivot Point, changing its Position, without /// changing its Orientation. /// </summary> /// <param name="fRotation">The Rotation in radians to apply to the object</param> /// <param name="sPivotPoint">The Point to rotate the object around</param> public void RotatePosition(float fRotation, Vector2 sPivotPoint) { // Rotate the object around the Pivot Point by the given Rotation angle mcPositionData.Position = PivotPoint2D.RotatePosition(fRotation, sPivotPoint, mcPositionData.Position); }