当前位置: 首页>>代码示例>>C#>>正文


C# Vector.Negate方法代码示例

本文整理汇总了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;
        }
开发者ID:villj2,项目名称:ch.bfh.bti7301.searchrobot,代码行数:28,代码来源:WayDecisionCollision.cs

示例2: Negate

		public void Negate ()
		{
			Vector v = new Vector (4, 5);
			v.Negate ();

			Assert.AreEqual (new Vector (-4, -5), v);
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:VectorTest.cs

示例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
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:67,代码来源:MainWindow.cs

示例4: Negated

 internal static Vector Negated(this Vector v)
 {
     var negated = new Vector(v.X, v.Y);
     negated.Negate();
     return negated;
 }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:6,代码来源:VectorExt.cs


注:本文中的System.Windows.Vector.Negate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。