Description
The RotateAround
method allows you to rotate a Vector3
instance around a specified center point using a given rotation. This method modifies the vector by applying the rotation around the center point, effectively changing its position in 3D space.
Usage
To use the RotateAround
method, you need to provide a reference to a Vector3
representing the center of rotation and a Rotation
object that defines the rotation to be applied. The method returns a new Vector3
that represents the rotated position.
Example
// Example of using RotateAround
Vector3 point = new Vector3(1, 0, 0);
Vector3 center = new Vector3(0, 0, 0);
Rotation rotation = Rotation.FromAxis(Vector3.Up, 90); // Rotate 90 degrees around the Y-axis
Vector3 rotatedPoint = point.RotateAround(ref center, ref rotation);
// rotatedPoint should now be approximately (0, 0, -1)