public void TestQuaternionAngleAxis() { var q = RIJK.AngleAxis(45, 2, 3, 4); var Q = Quaternion.AngleAxis(45, new Vector3(2, 3, 4)); var delta = 1e-4f; Assert.AreEqual(Q.x, q.i.x, delta); Assert.AreEqual(Q.y, q.j.y, delta); Assert.AreEqual(Q.z, q.k.z, delta); Assert.AreEqual(Q.w, q.r.w, delta); }
public void TestQuaternionMultiplication() { var f1 = 1f; var f2 = 2f; var f3 = 3f; var f4 = 4f; var f5 = -5f; var f6 = -6f; var f7 = -7f; var f8 = -8f; var q1 = new RIJK((I)f2, (J)f3, (K)f4, (R)f1).Normalized; var q2 = new RIJK((I)f6, (J)f7, (K)f8, (R)f5).Normalized; var q12 = q1 * q2; var uq1 = (RIJK)q1; var uq2 = (RIJK)q2; var q = (RIJK)q12; var Q1 = new Quaternion(f2, f3, f4, f1).normalized; var Q2 = new Quaternion(f6, f7, f8, f5).normalized; var Q = Q1 * Q2; Debug.Log(q12); Debug.Log($"Mine: {q}"); Debug.Log($"Unity: {Q}"); var delta = 1e-4f; Assert.AreEqual(Q1.w, uq1.r.w, delta); Assert.AreEqual(Q1.x, uq1.i.x, delta); Assert.AreEqual(Q1.y, uq1.j.y, delta); Assert.AreEqual(Q1.z, uq1.k.z, delta); Assert.AreEqual(Q2.w, uq2.r.w, delta); Assert.AreEqual(Q2.x, uq2.i.x, delta); Assert.AreEqual(Q2.y, uq2.j.y, delta); Assert.AreEqual(Q2.z, uq2.k.z, delta); Assert.AreEqual(Q.w, q.r.w, delta); Assert.AreEqual(Q.x, q.i.x, delta); Assert.AreEqual(Q.y, q.j.y, delta); Assert.AreEqual(Q.z, q.k.z, delta); }