本文整理汇总了C#中VectorD.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# VectorD.Normalize方法的具体用法?C# VectorD.Normalize怎么用?C# VectorD.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorD
的用法示例。
在下文中一共展示了VectorD.Normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NormalizeException
public void NormalizeException()
{
VectorD v = new VectorD(11);
v.Normalize();
}
示例2: AngleBetween
/// <summary>
/// Retrieves the angle, expressed in radians, between the two specified vectors.
/// </summary>
/// <param name="vector1">The first vector to evaluate.</param>
/// <param name="vector2">The second vector to evaluate.</param>
/// <returns>The angle, in radians, between vector1 and vector2.</returns>
public static double AngleBetween(VectorD vector1, VectorD vector2)
{
vector1.Normalize();
vector2.Normalize();
double angle = Math.Atan2(vector2.y, vector2.x) - Math.Atan2(vector1.y, vector1.x);
if (angle > Math.PI)
{
angle -= Math.PI * 2.0;
}
else if (angle < -Math.PI)
{
angle += Math.PI * 2.0;
}
return angle;
}
示例3: Normalize
public void Normalize()
{
VectorD v = new VectorD(new[] { 3.0, -1.0, 23.0, 0.4 });
v.Normalize();
Assert.IsTrue(v.IsNumericallyNormalized);
}