本文整理汇总了C#中Quaternion.Conjugate方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.Conjugate方法的具体用法?C# Quaternion.Conjugate怎么用?C# Quaternion.Conjugate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion.Conjugate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rotate
/// <summary>
/// Performs a rotation specified by a Quaternion on a Vector3.
/// </summary>
/// <param name="v">The Vector3 to rotate.</param>
/// <param name="q">The Quaternion representation of a rotation.</param>
/// <returns>The rotated Vector3.</returns>
public static Vector3 Rotate(Vector3 v, Quaternion q)
{
Quaternion result;
result = Quaternion.Multiply(q, new Quaternion(0.0, v));
result = Quaternion.Multiply(result, q.Conjugate());
return result.v;
}
示例2: Main
static void Main(string[] args)
{
Quaternion q = new Quaternion(1, 2, 3, 4);
Quaternion q1 = new Quaternion(2, 3, 4, 5);
Quaternion q2 = new Quaternion(3, 4, 5, 6);
double r = 7;
Console.WriteLine("q = {0}", q);
Console.WriteLine("q1 = {0}", q1);
Console.WriteLine("q2 = {0}", q2);
Console.WriteLine("r = {0}", r);
Console.WriteLine("q.Norm() = {0}", q.Norm());
Console.WriteLine("q1.Norm() = {0}", q1.Norm());
Console.WriteLine("q2.Norm() = {0}", q2.Norm());
Console.WriteLine("-q = {0}", -q);
Console.WriteLine("q.Conjugate() = {0}", q.Conjugate());
Console.WriteLine("q + r = {0}", q + r);
Console.WriteLine("q1 + q2 = {0}", q1 + q2);
Console.WriteLine("q2 + q1 = {0}", q2 + q1);
Console.WriteLine("q * r = {0}", q * r);
Console.WriteLine("q1 * q2 = {0}", q1 * q2);
Console.WriteLine("q2 * q1 = {0}", q2 * q1);
Console.WriteLine("q1*q2 {0} q2*q1", (q1 * q2) == (q2 * q1) ? "==" : "!=");
}
示例3: Test_Conjugate
public void Test_Conjugate()
{
var q = new Quaternion (180, 1, 0, 0);
var qConj = q.Conjugate ();
var expected = new Quaternion (180, -1, 0, 0);
Assert.AreEqual (expected, qConj);
}
示例4: TestConjugate
public void TestConjugate()
{
TK.Quaternion tkQ = TK.Quaternion.FromAxisAngle(TK.Vector3.UnitY, TK.MathHelper.PiOver2);
Quaternion q = new Quaternion(tkQ.W, tkQ.X, tkQ.Y, tkQ.Z);
tkQ.Conjugate();
q.Conjugate();
TestHelper.AssertEquals(tkQ.X, tkQ.Y, tkQ.Z, tkQ.W, q, "Testing conjugate");
}
示例5: Conjugate_ReturnsNegatedQuaternion
public void Conjugate_ReturnsNegatedQuaternion()
{
// Arrange
var q = new Quaternion(1, 1, 1, 1);
// Act
Quaternion result = q.Conjugate();
// Assert
Assert.That(result, Is.EqualTo(new Quaternion(-1, -1, -1, 1)));
}
示例6: Quaternion_Inverse_Test
public void Quaternion_Inverse_Test()
{
var q = new Quaternion(1.0f, 2.0f, 3.0f, 4.0f);
var expected = q.Conjugate() * (1 / q.Length);
Assert.AreEqual(expected, q.Inverse());
Assert.AreEqual(Quaternion.Zero, Quaternion.Zero.Inverse());
var q2 = SlimDX.Quaternion.Invert(new SlimDX.Quaternion(2.0f, 3.0f, 4.0f, 1.0f));
q2.Normalize();
Assert.AreEqual(q2.ToQuaternion(), q.Inverse());
}
示例7: Conjugate
public void Conjugate()
{
Quaternion q = new Quaternion(1, 2, 3, 4);
Quaternion expected = new Quaternion(-1, -2, -3, 4);
Compare(expected, Quaternion.Conjugate(q));
Quaternion result;
Quaternion.Conjugate(ref q, out result);
Compare(expected, result);
q.Conjugate();
Compare(expected, q);
}
示例8: CanRotateQuaternion
public void CanRotateQuaternion(double a, double b, double c, double d)
{
var quat = new Quaternion(a, b, c, d);
var quat180 = new Quaternion(0, 0, 1, 0);
var nonRotation = new Quaternion(0, 0, 0, 0);
var oneRotation = Quaternion.One;
Assert.AreEqual(quat180 * quat, quat.RotateRotationQuaternion(quat180));
Assert.AreEqual(oneRotation * quat, quat.RotateRotationQuaternion(oneRotation));
if (quat.IsUnitQuaternion)
{
Assert.AreEqual(quat * quat180 * quat.Conjugate(), quat.RotateUnitQuaternion(quat180));
Assert.AreEqual(quat * oneRotation * quat.Conjugate(), quat.RotateUnitQuaternion(oneRotation));
Assert.Throws<ArgumentException>(delegate { quat.RotateUnitQuaternion(nonRotation); });
Assert.Throws<ArgumentException>(delegate { quat.RotateRotationQuaternion(nonRotation); });
}
else
{
Assert.Throws<InvalidOperationException>(delegate { quat.RotateUnitQuaternion(quat180); });
Assert.Throws<InvalidOperationException>(delegate { quat.RotateUnitQuaternion(oneRotation); });
Assert.Throws<InvalidOperationException>(delegate { quat.RotateUnitQuaternion(nonRotation); });
}
}
示例9: 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 ());
}
示例10: QuaternionConjugateTest
public void QuaternionConjugateTest()
{
var a = new Quaternion(3.0f, 4.0f, 3.0f, 1.0f);
var expectedResult = new Quaternion(-3.0f, -4.0f, -3.0f, 1.0f);
a.Conjugate();
Assert.True(a.Equals(expectedResult, 1e-3f));
}
示例11: Rotate
public static Vector3 Rotate(Quaternion q, Vector3 v)
{
var conj = new Quaternion(q.ToArray());
conj.Conjugate();
Quaternion rotatedVector = conj * new Quaternion(v, 0) * q;
return new Vector3(rotatedVector.X, rotatedVector.Y, rotatedVector.Z);
}