本文整理汇总了C#中Quaternion.LengthSquared方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.LengthSquared方法的具体用法?C# Quaternion.LengthSquared怎么用?C# Quaternion.LengthSquared使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion.LengthSquared方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuaternionLengthSquaredTest
public void QuaternionLengthSquaredTest()
{
Vector3 v = new Vector3(1.0f, 2.0f, 3.0f);
float w = 4.0f;
Quaternion target = new Quaternion(v, w);
float expected = 30.0f;
float actual;
actual = target.LengthSquared();
Assert.True(MathHelper.Equal(expected, actual), "Quaternion.LengthSquared did not return the expected value.");
}
示例2: SetRotation
public static void SetRotation(ref Matrix m, Quaternion q)
{
float d = q.LengthSquared();
BulletDebug.Assert(d != 0);
float s = 2f / d;
float xs = q.X * s, ys = q.Y * s, zs = q.Z * s;
float wx = q.W * xs, wy = q.W * ys, wz = q.W * zs;
float xx = q.X * xs, xy = q.X * ys, xz = q.X * zs;
float yy = q.Y * ys, yz = q.Y * zs, zz = q.Z * zs;
m = new Matrix(1 - (yy + zz), xy - wz, xz + wy, 0,
xy + wz, 1 - (xx + zz), yz - wx, 0,
xz - wy, yz + wx, 1 - (xx + yy), 0,
m.M41, m.M42, m.M43, 1);
}
示例3: LengthSquared
public void LengthSquared()
{
Quaternion q1 = new Quaternion(1, 2, 3, 4);
Compare(30.0f, q1.LengthSquared());
}
示例4: Inverse
public static void Inverse (ref Quaternion quaternion, out Quaternion result)
{
// http://www.ncsa.illinois.edu/~kindr/emtc/quaternions/quaternion.c++
Quaternion conj = new Quaternion (quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
conj.Conjugate ();
result = conj * (1.0f / quaternion.LengthSquared ());
}