語言

Vector.Negate 方法

定義

能抵消這個向量。 向量大小與之前相同,但方向相反。

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

範例

以下範例展示了如何使用此方法來否定向量。

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

    // Make the direction of the Vector opposite but
    // leave the vector magnitude the same.
    // vectorResult is equal to (-20, -30)
    vectorResult.Negate();

    return vectorResult;
}

適用於

另請參閱