@Override public int compareTo(Quaterniond q) { return (int) Math.signum(lengthSquared() - q.lengthSquared()); }
@Override public int compareTo(Quaterniond q) { return (int) Math.signum(lengthSquared() - q.lengthSquared()); }
/** * Returns the length of this quaternion. * * @return The length */ @Override public double length() { return (double) Math.sqrt(lengthSquared()); }
/** * Returns the length of this quaternion. * * @return The length */ @Override public double length() { return (double) Math.sqrt(lengthSquared()); }
/** * Inverts the quaternion. <br> Inversion of a quaternion <code>a</code> returns quaternion <code>a<sup>-1</sup> = a' / |a|<sup>2</sup></code> where <code>a'</code> is {@link #conjugate() * conjugation} of <code>a</code>, and <code>|a|<sup>2</sup></code> is squared length of <code>a</code>. <br> For any quaternions <code>a, b, c</code>, such that <code>a * b = c</code> equations * <code>a<sup>-1</sup> * c = b</code> and <code>c * b<sup>-1</sup> = a</code> are true. * * @return the inverted quaternion */ @Override public Quaterniond invert() { final double lengthSquared = lengthSquared(); if (Math.abs(lengthSquared) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot invert a quaternion of length zero"); } return conjugate().div(lengthSquared); }
/** * Inverts the quaternion. <br> Inversion of a quaternion <code>a</code> returns quaternion <code>a<sup>-1</sup> = a' / |a|<sup>2</sup></code> where <code>a'</code> is {@link #conjugate() * conjugation} of <code>a</code>, and <code>|a|<sup>2</sup></code> is squared length of <code>a</code>. <br> For any quaternions <code>a, b, c</code>, such that <code>a * b = c</code> equations * <code>a<sup>-1</sup> * c = b</code> and <code>c * b<sup>-1</sup> = a</code> are true. * * @return the inverted quaternion */ @Override public Quaterniond invert() { final double lengthSquared = lengthSquared(); if (Math.abs(lengthSquared) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot invert a quaternion of length zero"); } return conjugate().div(lengthSquared); }