Rotate

Matrix4.Rotate method (1 of 2)

Create a rotation matrix by rotation angle and axis

public static Matrix4 Rotate(double angle, Vector3 axis)
ParameterTypeDescription
angleDoubleRotate angle in radian
axisVector3Rotation axis

Examples

The following code shows how to create a matrix for rotate operation.

var t = Matrix4.Rotate(Math.PI, new Vector3(0, 1, 0));
var pos = new Vector3(1, 1, 10);
Console.WriteLine($"Transformed: {t * pos}");

See Also


Matrix4.Rotate method (2 of 2)

Create a rotation matrix from a quaternion

public static Matrix4 Rotate(Quaternion q)
ParameterTypeDescription
qQuaternionRotation quaternion

Examples

The following code shows how to create a matrix for rotate operation.

var t = Matrix4.Rotate(Quaternion.FromAngleAxis(Math.PI, Vector3.YAxis));
var pos = new Vector3(1, 1, 10);
Console.WriteLine($"Transformed: {t * pos}");

See Also