/** * Checks whether the instance is a unit quaternion within a given * tolerance. * * @param eps Tolerance (absolute error). * @return {@code true} if the norm is 1 within the given tolerance, * {@code false} otherwise */ public boolean isUnitQuaternion(double eps) { return Precision.equals(getNorm(), 1d, eps); }
/** * Computes the normalized quaternion (the versor of the instance). * The norm of the quaternion must not be zero. * * @return a normalized quaternion. * @throws ZeroException if the norm of the quaternion is zero. */ public Quaternion normalize() { final double norm = getNorm(); if (norm < Precision.SAFE_MIN) { throw new ZeroException(LocalizedFormats.NORM, norm); } return new Quaternion(q0 / norm, q1 / norm, q2 / norm, q3 / norm); }
/** * Checks whether the instance is a unit quaternion within a given * tolerance. * * @param eps Tolerance (absolute error). * @return {@code true} if the norm is 1 within the given tolerance, * {@code false} otherwise */ public boolean isUnitQuaternion(double eps) { return Precision.equals(getNorm(), 1d, eps); }
/** * Checks whether the instance is a unit quaternion within a given * tolerance. * * @param eps Tolerance (absolute error). * @return {@code true} if the norm is 1 within the given tolerance, * {@code false} otherwise */ public boolean isUnitQuaternion(double eps) { return Precision.equals(getNorm(), 1d, eps); }
/** * Computes the normalized quaternion (the versor of the instance). * The norm of the quaternion must not be zero. * * @return a normalized quaternion. * @throws ZeroException if the norm of the quaternion is zero. */ public Quaternion normalize() { final double norm = getNorm(); if (norm < Precision.SAFE_MIN) { throw new ZeroException(LocalizedFormats.NORM, norm); } return new Quaternion(q0 / norm, q1 / norm, q2 / norm, q3 / norm); }
/** * Computes the normalized quaternion (the versor of the instance). * The norm of the quaternion must not be zero. * * @return a normalized quaternion. * @throws ZeroException if the norm of the quaternion is zero. */ public Quaternion normalize() { final double norm = getNorm(); if (norm < Precision.SAFE_MIN) { throw new ZeroException(LocalizedFormats.NORM, norm); } return new Quaternion(q0 / norm, q1 / norm, q2 / norm, q3 / norm); }