Java Code Examples for org.apache.commons.math.util.MathUtils#normalizeAngle()

The following examples show how to use org.apache.commons.math.util.MathUtils#normalizeAngle() . 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: Line.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Copy constructor.
 * <p>The created instance is completely independant from the
 * original instance, it is a deep copy.</p>
 * @param line line to copy
 */
public Line(final Line line) {
    angle        = MathUtils.normalizeAngle(line.angle, FastMath.PI);
    cos          = FastMath.cos(angle);
    sin          = FastMath.sin(angle);
    originOffset = line.originOffset;
}
 
Example 2
Source File: Line.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Reset the instance as if built from a line and an angle.
 * @param p point belonging to the line
 * @param alpha angle of the line with respect to abscissa axis
 */
public void reset(final Vector2D p, final double alpha) {
    this.angle   = MathUtils.normalizeAngle(alpha, FastMath.PI);
    cos          = FastMath.cos(this.angle);
    sin          = FastMath.sin(this.angle);
    originOffset = cos * p.getY() - sin * p.getX();
}
 
Example 3
Source File: Line.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Copy constructor.
 * <p>The created instance is completely independant from the
 * original instance, it is a deep copy.</p>
 * @param line line to copy
 */
public Line(final Line line) {
    angle        = MathUtils.normalizeAngle(line.angle, FastMath.PI);
    cos          = FastMath.cos(angle);
    sin          = FastMath.sin(angle);
    originOffset = line.originOffset;
}
 
Example 4
Source File: Line.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Reset the instance as if built from a line and an angle.
 * @param p point belonging to the line
 * @param alpha angle of the line with respect to abscissa axis
 */
public void reset(final Vector2D p, final double alpha) {
    this.angle   = MathUtils.normalizeAngle(alpha, FastMath.PI);
    cos          = FastMath.cos(this.angle);
    sin          = FastMath.sin(this.angle);
    originOffset = cos * p.getY() - sin * p.getX();
}
 
Example 5
Source File: Line.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Get the angle of the line.
 * @return the angle of the line with respect to the abscissa axis
 */
public double getAngle() {
    return MathUtils.normalizeAngle(angle, FastMath.PI);
}
 
Example 6
Source File: Line.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Set the angle of the line.
 * @param angle new angle of the line with respect to the abscissa axis
 */
public void setAngle(final double angle) {
    this.angle = MathUtils.normalizeAngle(angle, FastMath.PI);
    cos        = FastMath.cos(this.angle);
    sin        = FastMath.sin(this.angle);
}
 
Example 7
Source File: Line.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Get the angle of the line.
 * @return the angle of the line with respect to the abscissa axis
 */
public double getAngle() {
    return MathUtils.normalizeAngle(angle, FastMath.PI);
}
 
Example 8
Source File: Line.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Set the angle of the line.
 * @param angle new angle of the line with respect to the abscissa axis
 */
public void setAngle(final double angle) {
    this.angle = MathUtils.normalizeAngle(angle, FastMath.PI);
    cos        = FastMath.cos(this.angle);
    sin        = FastMath.sin(this.angle);
}