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;
}

適用於

另請參閱