次の方法で共有


How to: Transform a Point with a Matrix

This example demonstrates how to use the Vector3 and Matrix classes to transform a point.

To transform a point

  1. Create a Matrix by using CreateRotationY or one of the other Create methods.
  2. Pass the point and the Matrix to the Vector3.Transform method.
static Vector3 RotatePointOnYAxis( Vector3 point, float angle )
{
    // Create a rotation matrix that represents a rotation of angle radians.
    Matrix rotationMatrix = Matrix.CreateRotationY( angle );

    // Apply the rotation matrix to the point.
    Vector3 rotatedPoint = Vector3.Transform( point, rotationMatrix );

    return rotatedPoint;
}

See Also

Matrix Creation Methods

CreateRotationX
CreateRotationY
CreateRotationZ
CreateScale
CreateTranslation