Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#NORM

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#NORM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the inverse of this instance.
 * The norm of the quaternion must not be zero.
 *
 * @return the inverse.
 * @throws ZeroException if the norm (squared) of the quaternion is zero.
 */
public Quaternion getInverse() {
    final double squareNorm = q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3;
    if (squareNorm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, squareNorm);
    }

    return new Quaternion(q0 / squareNorm,
                          -q1 / squareNorm,
                          -q2 / squareNorm,
                          -q3 / squareNorm);
}
 
Example 3
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 4
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the inverse of this instance.
 * The norm of the quaternion must not be zero.
 *
 * @return the inverse.
 * @throws ZeroException if the norm (squared) of the quaternion is zero.
 */
public Quaternion getInverse() {
    final double squareNorm = q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3;
    if (squareNorm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, squareNorm);
    }

    return new Quaternion(q0 / squareNorm,
                          -q1 / squareNorm,
                          -q2 / squareNorm,
                          -q3 / squareNorm);
}
 
Example 5
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the inverse of this instance.
 * The norm of the quaternion must not be zero.
 *
 * @return the inverse.
 * @throws ZeroException if the norm (squared) of the quaternion is zero.
 */
public Quaternion getInverse() {
    final double squareNorm = q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3;
    if (squareNorm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, squareNorm);
    }

    return new Quaternion(q0 / squareNorm,
                          -q1 / squareNorm,
                          -q2 / squareNorm,
                          -q3 / squareNorm);
}
 
Example 7
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the inverse of this instance.
 * The norm of the quaternion must not be zero.
 *
 * @return the inverse.
 * @throws ZeroException if the norm (squared) of the quaternion is zero.
 */
public Quaternion getInverse() {
    final double squareNorm = q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3;
    if (squareNorm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, squareNorm);
    }

    return new Quaternion(q0 / squareNorm,
                          -q1 / squareNorm,
                          -q2 / squareNorm,
                          -q3 / squareNorm);
}
 
Example 9
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the inverse of this instance.
 * The norm of the quaternion must not be zero.
 *
 * @return the inverse.
 * @throws ZeroException if the norm (squared) of the quaternion is zero.
 */
public Quaternion getInverse() {
    final double squareNorm = q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3;
    if (squareNorm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, squareNorm);
    }

    return new Quaternion(q0 / squareNorm,
                          -q1 / squareNorm,
                          -q2 / squareNorm,
                          -q3 / squareNorm);
}
 
Example 11
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: Quaternion.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the inverse of this instance.
 * The norm of the quaternion must not be zero.
 *
 * @return the inverse.
 * @throws ZeroException if the norm (squared) of the quaternion is zero.
 */
public Quaternion getInverse() {
    final double squareNorm = q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3;
    if (squareNorm < Precision.SAFE_MIN) {
        throw new ZeroException(LocalizedFormats.NORM, squareNorm);
    }

    return new Quaternion(q0 / squareNorm,
                          -q1 / squareNorm,
                          -q2 / squareNorm,
                          -q3 / squareNorm);
}