bool AlmostEqual( Rotation& r, float delta )

book_4_sparkGenerated
code_blocksInput

Description

The AlmostEqual method in the Rotation struct is used to determine if two rotations are approximately equal within a specified tolerance. This method is useful when you need to compare rotations but want to allow for minor differences that may arise due to floating-point precision errors.

Usage

To use the AlmostEqual method, you need to provide a reference to a Rotation object and a float value representing the tolerance level. The method will return true if the current rotation is approximately equal to the provided rotation within the specified delta, otherwise it returns false.

Example

// Example usage of the AlmostEqual method
Rotation rotation1 = Rotation.FromAxis(Vector3.Up, 45);
Rotation rotation2 = Rotation.FromAxis(Vector3.Up, 45.1f);

float tolerance = 0.2f;
bool areAlmostEqual = rotation1.AlmostEqual(ref rotation2, tolerance);

// areAlmostEqual will be true if the difference between rotation1 and rotation2 is less than or equal to 0.2 degrees.