Quaternion implements Serializable { public boolean isUnitQuaternion(double eps) { return Precision.equals(getNorm(), 1d, eps); } 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 testIsUnitQuaternion() { final Random r = new Random(48); final int numberOfTrials = 1000; for (int i = 0; i < numberOfTrials; i++) { final Quaternion q1 = new Quaternion(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble()); final Quaternion q2 = q1.normalize(); Assert.assertTrue(q2.isUnitQuaternion(COMPARISON_EPS)); } final Quaternion q = new Quaternion(1, 1, 1, 1); Assert.assertFalse(q.isUnitQuaternion(COMPARISON_EPS)); }