本文整理汇总了C#中Vector4F.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4F.Normalize方法的具体用法?C# Vector4F.Normalize怎么用?C# Vector4F.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector4F
的用法示例。
在下文中一共展示了Vector4F.Normalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Normalize
public void Normalize()
{
Vector4F v, n1, n2;
float magnitude;
v = new Vector4F(3.0f, 4.0f, 0.0f, 0.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);
v = new Vector4F(3.0f, 0.0f, 4.0f, 0.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);
v = new Vector4F(0.0f, 3.0f, 4.0f, 0.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);
v = new Vector4F(0.0f, 0.0f, 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);
}
示例2: NormalizeZeroVector
public void NormalizeZeroVector()
{
Vector4F v = new Vector4F(0.0f, 0.0f, 0.0f, 0.0f);
Vector4F n1 = v.Normalize();
Assert.IsNaN(n1.X);
Assert.IsNaN(n1.Y);
Assert.IsNaN(n1.Z);
Assert.IsTrue(n1.IsUndefined);
float magnitude;
Vector4F n2 = v.Normalize(out magnitude);
Assert.IsNaN(n2.X);
Assert.IsNaN(n2.Y);
Assert.IsNaN(n2.Z);
Assert.IsTrue(n2.IsUndefined);
Assert.AreEqual(0.0f, magnitude);
}
示例3: Normalize
public void Normalize()
{
Vector4F v = new Vector4F(3.0f, -1.0f, 23.0f, 0.4f);
v.Normalize();
Assert.IsTrue(v.IsNumericallyNormalized);
}