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

适用于

另请参阅