本文整理汇总了C#中System.Windows.Vector.Negate方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Negate方法的具体用法?C# Vector.Negate怎么用?C# Vector.Negate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Vector
的用法示例。
在下文中一共展示了Vector.Negate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWaypoint
public override Point GetWaypoint()
{
// update collided point status
_me.SetStatus(_mo.X, _mo.Y, MapElementStatus.Collided);
Vector vector = new Vector(_mo.X - _posX, _mo.Y - _posY);
// opposite direction
vector.Negate();
// normalize vector (length = 1)
vector.Normalize();
// calculate distances to every border
double tLeft = (-_posX) / vector.X;
double tRight = (800 - _posX) / vector.X;
double tTop = (-_posY) / vector.Y;
double tBottom = (600 - _posY) / vector.Y;
vector *= 20;
_point.X = (int)_posX + (int)vector.X;
_point.Y = (int)_posY + (int)vector.Y;
_point.Status = MapElementStatus.Waypoint;
return _point;
}
示例2: Negate
public void Negate ()
{
Vector v = new Vector (4, 5);
v.Negate ();
Assert.AreEqual (new Vector (-4, -5), v);
}
示例3: PerformOperation
//.........这里部分代码省略.........
// Displaying Results
syntaxString = "vectorResult = Vector.Parse(\"1,3\");";
resultType = "Vector";
operationString = "Converting a string into a Vector";
ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb28":
{
// Checks if two Vectors are not equal using the overloaded inequality operator.
var vector1 = new System.Windows.Vector(20, 30);
var vector2 = new System.Windows.Vector(45, 70);
var areNotEqual = (vector1 != vector2);
// areNotEqual is True
// Displaying Results
syntaxString = "areNotEqual = (vector1 != vector2);";
resultType = "Boolean";
operationString = "Checking if two points are not equal";
ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb29":
{
// Negates a Vector using the Negate method.
var vector1 = new System.Windows.Vector(20, 30);
vector1.Negate();
// vector1 is equal to (-20, -30)
// Displaying Results
syntaxString = "vector1.Negate();";
resultType = "void";
operationString = "Negating a vector";
ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb30":
{
// Negates a Vector using the overloaded unary negation operator.
var vector1 = new System.Windows.Vector(20, 30);
var vectorResult = -vector1;
// vectorResult is equal to (-20, -30)
// Displaying Results
syntaxString = "vectorResult = -vector1;";
resultType = "Vector";
operationString = "Negating a vector";
ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb31":
{
// Gets a String representation of a Vector structure
示例4: Negated
internal static Vector Negated(this Vector v)
{
var negated = new Vector(v.X, v.Y);
negated.Negate();
return negated;
}