Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Copies the given PivotPoint2D object's data into this object's data
        /// </summary>
        /// <param name="cPivotPointToCopy"></param>
        public void CopyFrom(PivotPoint2D cPivotPointToCopy)
        {
            PivotPoint = cPivotPointToCopy.PivotPoint;
            PivotRotationalVelocity     = cPivotPointToCopy.PivotRotationalVelocity;
            PivotRotationalAcceleration = cPivotPointToCopy.PivotRotationalAcceleration;
            mbRotateOrientationToo      = cPivotPointToCopy.RotateOrientationToo;

            mcPositionData    = new Position2D(cPivotPointToCopy.PositionData);
            mcOrientationData = new Orientation2D(cPivotPointToCopy.OrientationData);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Rotates the given Position and Orientation around the Pivot Point, changing the Position and Orientation.
        /// <para>NOTE: The Pivot Point and Position's Z-values are ignored.</para>
        /// <para>NOTE: This function is provided for convenience when using 3D Vectors in 2D coordinate systems.</para>
        /// </summary>
        /// <param name="fRotation">The Rotation in radians to apply to the object</param>
        /// <param name="sPivotPoint">The Point to rotate the object around.
        /// NOTE: The Z-value is ignored, since this is a 2D rotation.</param>
        /// <param name="srPosition">The Position of the object to be modified.
        /// NOTE: The Z-value is ignored and will not be changed, since this is a 2D rotation.</param>
        /// <param name="frOrientation">The Orientation (rotation) of the object to be modified</param>
        public static void RotatePositionAndOrientationVector3(float fRotation, Vector3 sPivotPoint, ref Vector3 srPosition, ref float frOrientation)
        {
            // Set up the Position vector to pass by reference
            Vector2 sPosition2D = new Vector2(srPosition.X, srPosition.Y);

            // Call the 2D function to perform the operations
            PivotPoint2D.RotatePositionAndOrientation(fRotation, new Vector2(sPivotPoint.X, sPivotPoint.Y),
                                                      ref sPosition2D, ref frOrientation);

            // Set the Position's 2D position to the new Rotated Position (leaving the Z-value unchanged)
            srPosition.X = sPosition2D.X;
            srPosition.Y = sPosition2D.Y;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="cPivotPointToCopy">The PivotPoint2D object to copy</param>
 public PivotPoint2D(PivotPoint2D cPivotPointToCopy)
 {
     CopyFrom(cPivotPointToCopy);
 }
Exemplo n.º 6
0
 /// <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);
 }