Rotation Clamp( Rotation to, float degrees )
Rotation Clamp( Rotation to, float degrees, System.Single& change )

robot_2Generated
code_blocksInput

Description

The Clamp method in the Rotation struct is used to limit the rotation to a specified angle range. It adjusts the current rotation to be within a certain number of degrees from a target rotation.

Usage

To use the Clamp method, you need to have an instance of the Rotation struct. You can then call this method to adjust the rotation towards a target rotation, ensuring that the change does not exceed a specified number of degrees.

The method takes two parameters:

  • to: A Rotation object representing the target rotation you want to clamp towards.
  • degrees: A float value specifying the maximum number of degrees the rotation can change.

Example

// Example of using the Clamp method
Rotation currentRotation = new Rotation();
Rotation targetRotation = Rotation.FromAxis(new Vector3(0, 1, 0), 90);
float maxDegrees = 45.0f;

// Clamp the current rotation towards the target rotation
Rotation clampedRotation = currentRotation.Clamp(targetRotation, maxDegrees);

// The clampedRotation will now be within 45 degrees of the targetRotation.