当前位置: 首页>>代码示例>>C#>>正文


C# Quaternion.Conjugate方法代码示例

本文整理汇总了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;
 }
开发者ID:SSheldon,项目名称:veccalc,代码行数:13,代码来源:Quaternion.cs

示例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) ? "==" : "!=");
    }
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:29,代码来源:quaternion-type-2.cs

示例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);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:8,代码来源:TestQuaternion.cs

示例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");
        }
开发者ID:hasanabb,项目名称:assimp-net,代码行数:10,代码来源:QuaternionTestFixture.cs

示例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)));
        }
开发者ID:GeirGrusom,项目名称:ModGL,代码行数:11,代码来源:QuaternionTests.cs

示例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());
        }
开发者ID:HaKDMoDz,项目名称:Irelia,代码行数:12,代码来源:QuaternionTest.cs

示例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);
        }
开发者ID:SvDvorak,项目名称:Mono.GameMath,代码行数:13,代码来源:QuaternionTest.cs

示例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); });

            }
        }
开发者ID:djowatts,项目名称:mathnet-spatial,代码行数:24,代码来源:QuaternionTests.cs

示例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 ());
		}
开发者ID:SergioEstevao,项目名称:Mono.GameMath,代码行数:8,代码来源:Quaternion.cs

示例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));
        }
开发者ID:richardhallett,项目名称:nml,代码行数:9,代码来源:QuaternionTests.cs

示例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);
        }
开发者ID:Ruodan,项目名称:Gygax,代码行数:9,代码来源:CameraPosition.cs


注:本文中的Quaternion.Conjugate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。