Vector.Negate 方法

定义

对此向量求反。Negates this vector. 向量的大小与以前相同,但现在的方向与以前相反。The vector has the same magnitude as before, but its direction is now opposite.

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

示例

下面的示例演示如何使用此方法来否定矢量。The following example shows how to use this method to negate a vector.

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;

}

适用于

另请参阅