Quaternion implements Serializable { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other instanceof Quaternion) { final Quaternion q = (Quaternion) other; return q0 == q.getQ0() && q1 == q.getQ1() && q2 == q.getQ2() && q3 == q.getQ3(); } return false; } Quaternion(final double a,
                      final double b,
                      final double c,
                      final double d);  Quaternion(final double scalar,
                      final double[] v);  Quaternion(final double[] v); Quaternion getConjugate(); static Quaternion multiply(final Quaternion q1, final Quaternion q2); Quaternion multiply(final Quaternion q); static Quaternion add(final Quaternion q1,
                                 final Quaternion q2); Quaternion add(final Quaternion q); static Quaternion subtract(final Quaternion q1,
                                      final Quaternion q2); Quaternion subtract(final Quaternion q); static double dotProduct(final Quaternion q1,
                                    final Quaternion q2); double dotProduct(final Quaternion q); double getNorm(); Quaternion normalize(); @Override boolean equals(Object other); @Override int hashCode(); boolean equals(final Quaternion q,
                          final double eps); boolean isUnitQuaternion(double eps); boolean isPureQuaternion(double eps); Quaternion getPositivePolarForm(); Quaternion getInverse(); double getQ0(); double getQ1(); double getQ2(); double getQ3(); double getScalarPart(); double[] getVectorPart(); Quaternion multiply(final double alpha); @Override String toString(); static final Quaternion IDENTITY; static final Quaternion ZERO; static final Quaternion I; static final Quaternion J; static final Quaternion K; }
@Test public final void testObjectEquals() { final double one = 1; final Quaternion q1 = new Quaternion(one, one, one, one); Assert.assertTrue(q1.equals(q1)); final Quaternion q2 = new Quaternion(one, one, one, one); Assert.assertTrue(q2.equals(q1)); final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one); Assert.assertFalse(q3.equals(q1)); }
@Test public final void testQuaternionEquals2() { final Quaternion q1 = new Quaternion(1, 4, 2, 3); final double gap = 1e-5; final Quaternion q2 = new Quaternion(1 + gap, 4 + gap, 2 + gap, 3 + gap); Assert.assertTrue(q1.equals(q2, 10 * gap)); Assert.assertFalse(q1.equals(q2, gap)); Assert.assertFalse(q1.equals(q2, gap / 10)); }