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


C# Vector2F.Normalize方法代码示例

本文整理汇总了C#中Vector2F.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2F.Normalize方法的具体用法?C# Vector2F.Normalize怎么用?C# Vector2F.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector2F的用法示例。


在下文中一共展示了Vector2F.Normalize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Normalize

        public void Normalize()
        {
            Vector2F v, n1, n2;
            float magnitude;

            v = new Vector2F(3.0f, 4.0f);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0f, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0f, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0f, magnitude, 1e-14);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:12,代码来源:Vector2FTests.cs

示例2: NormalizeZeroVector

        public void NormalizeZeroVector()
        {
            Vector2F v = new Vector2F(0.0f, 0.0f);

            Vector2F n1 = v.Normalize();
            Assert.IsNaN(n1.X);
            Assert.IsNaN(n1.Y);
            Assert.IsTrue(n1.IsUndefined);

            float magnitude;
            Vector2F n2 = v.Normalize(out magnitude);
            Assert.IsNaN(n2.X);
            Assert.IsNaN(n2.Y);
            Assert.IsTrue(n2.IsUndefined);
            Assert.AreEqual(0.0f, magnitude);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:16,代码来源:Vector2FTests.cs

示例3: DrawArrow

        private void DrawArrow(PaintEventArgs e, Pen pen, float x1, float y1, float x2, float y2, float fPtrSize, bool bStart, bool bEnd)
        {
            e.Graphics.DrawLine(pen, x1, y1, x2, y2);
              Vector2F dir = new Vector2F(x2 - x1, y2 - y1);
              dir.Normalize();
              dir *= fPtrSize;

              if (bStart)
              {
            e.Graphics.DrawLine(pen, x1, y1, x1 + dir.X + dir.Y, y1 + dir.Y - dir.X);
            e.Graphics.DrawLine(pen, x1, y1, x1 + dir.X - dir.Y, y1 + dir.Y + dir.X);
              }
              if (bEnd)
              {
            e.Graphics.DrawLine(pen, x2, y2, x2 - dir.X + dir.Y, y2 - dir.Y - dir.X);
            e.Graphics.DrawLine(pen, x2, y2, x2 - dir.X - dir.Y, y2 - dir.Y + dir.X);
              }
        }
开发者ID:romance-ii,项目名称:projectanarchy,代码行数:18,代码来源:TerrainConfigDlg.cs

示例4: Normalize

 public void Normalize()
 {
     Vector2F v = new Vector2F(3.0f, -1.0f);
       v.Normalize();
       Assert.IsTrue(v.IsNumericallyNormalized);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:6,代码来源:Vector2FTest.cs

示例5: FromVector

 /// <summary>
 ///   Returns the angle between the specified vector and the x-axis.
 ///   Example: FromVector(0.5, 0.5) will return DegreesToRadians(45).
 /// </summary>
 /// <remarks>
 ///   See http://stackoverflow.com/questions/6247153/angle-from-2d-unit-vector for details.
 /// </remarks>
 /// <param name="v">Vector to get the angle of.</param>
 /// <returns>Angle between the specified vector and the x-axis.</returns>
 public static float FromVector(Vector2F v)
 {
     var normalized = v.Normalize();
     return Atan2(normalized.Y, normalized.X);
 }
开发者ID:npruehs,项目名称:game-math,代码行数:14,代码来源:Angle.cs


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