The Matrix.CreateRotation
method creates a rotation matrix from a given Rotation
object. This method is useful for transforming objects in 3D space by applying a rotation defined by the Rotation
parameter.
The Matrix.CreateRotation
method creates a rotation matrix from a given Rotation
object. This method is useful for transforming objects in 3D space by applying a rotation defined by the Rotation
parameter.
To use the CreateRotation
method, pass a Rotation
object that defines the desired rotation. The method will return a Matrix
that represents this rotation, which can then be used to transform other objects or combined with other matrices for complex transformations.
// Example of creating a rotation matrix using a Rotation object Rotation rotation = new Rotation(0, 90, 0); // Rotate 90 degrees around the Y-axis Matrix rotationMatrix = Matrix.CreateRotation(rotation); // Use the rotation matrix to transform a vector Vector3 originalVector = new Vector3(1, 0, 0); Vector3 transformedVector = rotationMatrix.Transform(originalVector); // transformedVector should now be (0, 0, -1) after a 90-degree rotation around the Y-axis