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