Vector.Normalize 方法

定义

规范化此向量。Normalizes this vector.

public:
 void Normalize();
public void Normalize ();
member this.Normalize : unit -> unit
Public Sub Normalize ()

示例

下面的示例演示如何使用此方法规范化向量。The following example shows how to use this method to normalize a vector.

private Vector normalizeExample()
{
    Vector vectorResult = new Vector(20, 30);

    // A normalized vector maintains its direction but 
    // its length becomes 1. 
    // vectorResult is approximately equal to (0.5547,0.8321).
    vectorResult.Normalize();

    return vectorResult;

}

注解

规范化向量保持其方向, 但其Length变为1。A normalized vector maintains its direction but its Length becomes 1. 生成的向量通常称为单位矢量。The resulting vector is often called a unit vector. 使用向量除以向量Length, 将向量标准化。A vector is normalized by dividing the vector by its own Length.

适用于