Description
The SnapToGrid
method adjusts the angles to the nearest grid point based on the specified grid size. This method allows you to snap the pitch, yaw, and roll components of the angles to a grid, which can be useful for aligning objects in a scene or ensuring consistent rotations.
Usage
To use the SnapToGrid
method, call it on an instance of the Angles
struct. Provide the grid size and specify which components (pitch, yaw, roll) should be snapped by setting the corresponding boolean parameters to true
or false
.
Example
// Create an instance of Angles
Angles angles = new Angles(45.0f, 30.0f, 60.0f);
// Snap the angles to a grid of size 10, snapping only the pitch and yaw
Angles snappedAngles = angles.SnapToGrid(10.0f, true, true, false);
// Output the snapped angles
// snappedAngles will have pitch and yaw adjusted to the nearest multiple of 10,
// while roll remains unchanged.