本文整理汇总了C#中Quaternion.Length方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.Length方法的具体用法?C# Quaternion.Length怎么用?C# Quaternion.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion.Length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuaternionLengthTest
public void QuaternionLengthTest()
{
Vector3 v = new Vector3(1.0f, 2.0f, 3.0f);
float w = 4.0f;
Quaternion target = new Quaternion(v, w);
float expected = 5.477226f;
float actual;
actual = target.Length();
Assert.True(MathHelper.Equal(expected, actual), "Quaternion.Length did not return the expected value.");
}
示例2: Normalize
public static void Normalize (ref Quaternion quaternion, out Quaternion result)
{
// TODO: SIMD optimization
Multiply (ref quaternion, 1.0f / quaternion.Length (), out result);
}
示例3: Length
public void Length()
{
Quaternion q1 = new Quaternion(1, 2, 3, 4);
Compare(5.477226f, q1.Length());
}
示例4: Normalize
/// <summary>
/// Computes a unit length Quaternion
/// </summary>
/// <param name="q">the quaternion to compute from</param>
/// <returns>the normalized quaternion representation of the specified quaternion</returns>
public static Quaternion Normalize(Quaternion q)
{
Quaternion o = new Quaternion(q);
float mag = q.Length();
o /= mag;
o /= mag;
o /= mag;
o /= mag;
return o;
}