Java Code Examples for org.apache.commons.math3.util.FastMath#atan2()
The following examples show how to use
org.apache.commons.math3.util.FastMath#atan2() .
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 | 6 votes |
/** Reset the instance as if built from two points. * <p>The line is oriented from p1 to p2</p> * @param p1 first point * @param p2 second point */ public void reset(final Vector2D p1, final Vector2D p2) { final double dx = p2.getX() - p1.getX(); final double dy = p2.getY() - p1.getY(); final double d = FastMath.hypot(dx, dy); if (d == 0.0) { angle = 0.0; cos = 1.0; sin = 0.0; originOffset = p1.getY(); } else { angle = FastMath.PI + FastMath.atan2(-dy, -dx); cos = FastMath.cos(angle); sin = FastMath.sin(angle); originOffset = (p2.getX() * p1.getY() - p1.getX() * p2.getY()) / d; } }
Example 2
Source File: Line.java From astor with GNU General Public License v2.0 | 6 votes |
/** Reset the instance as if built from two points. * <p>The line is oriented from p1 to p2</p> * @param p1 first point * @param p2 second point */ public void reset(final Vector2D p1, final Vector2D p2) { final double dx = p2.getX() - p1.getX(); final double dy = p2.getY() - p1.getY(); final double d = FastMath.hypot(dx, dy); if (d == 0.0) { angle = 0.0; cos = 1.0; sin = 0.0; originOffset = p1.getY(); } else { angle = FastMath.PI + FastMath.atan2(-dy, -dx); cos = FastMath.cos(angle); sin = FastMath.sin(angle); originOffset = (p2.getX() * p1.getY() - p1.getX() * p2.getY()) / d; } }
Example 3
Source File: HarmonicFitter.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Estimate a first guess of the phase. * * @param observations Observations, sorted w.r.t. abscissa. * @return the guessed phase. */ private double guessPhi(WeightedObservedPoint[] observations) { // initialize the means double fcMean = 0; double fsMean = 0; double currentX = observations[0].getX(); double currentY = observations[0].getY(); for (int i = 1; i < observations.length; ++i) { // one step forward final double previousX = currentX; final double previousY = currentY; currentX = observations[i].getX(); currentY = observations[i].getY(); final double currentYPrime = (currentY - previousY) / (currentX - previousX); double omegaX = omega * currentX; double cosine = FastMath.cos(omegaX); double sine = FastMath.sin(omegaX); fcMean += omega * currentY * cosine - currentYPrime * sine; fsMean += omega * currentY * sine + currentYPrime * cosine; } return FastMath.atan2(-fsMean, fcMean); }
Example 4
Source File: HarmonicFitter.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Estimate a first guess of the phase. * * @param observations Observations, sorted w.r.t. abscissa. * @return the guessed phase. */ private double guessPhi(WeightedObservedPoint[] observations) { // initialize the means double fcMean = 0; double fsMean = 0; double currentX = observations[0].getX(); double currentY = observations[0].getY(); for (int i = 1; i < observations.length; ++i) { // one step forward final double previousX = currentX; final double previousY = currentY; currentX = observations[i].getX(); currentY = observations[i].getY(); final double currentYPrime = (currentY - previousY) / (currentX - previousX); double omegaX = omega * currentX; double cosine = FastMath.cos(omegaX); double sine = FastMath.sin(omegaX); fcMean += omega * currentY * cosine - currentYPrime * sine; fsMean += omega * currentY * sine + currentYPrime * cosine; } return FastMath.atan2(-fsMean, fcMean); }
Example 5
Source File: NPEfix_00169_s.java From coming with MIT License | 6 votes |
/** Reset the instance as if built from two points. * <p>The line is oriented from p1 to p2</p> * @param p1 first point * @param p2 second point */ public void reset(final Vector2D p1, final Vector2D p2) { final double dx = p2.getX() - p1.getX(); final double dy = p2.getY() - p1.getY(); final double d = FastMath.hypot(dx, dy); if (d == 0.0) { angle = 0.0; cos = 1.0; sin = 0.0; originOffset = p1.getY(); } else { angle = FastMath.PI + FastMath.atan2(-dy, -dx); cos = FastMath.cos(angle); sin = FastMath.sin(angle); originOffset = (p2.getX() * p1.getY() - p1.getX() * p2.getY()) / d; } }
Example 6
Source File: Line.java From astor with GNU General Public License v2.0 | 6 votes |
/** Reset the instance as if built from two points. * <p>The line is oriented from p1 to p2</p> * @param p1 first point * @param p2 second point */ public void reset(final Vector2D p1, final Vector2D p2) { final double dx = p2.getX() - p1.getX(); final double dy = p2.getY() - p1.getY(); final double d = FastMath.hypot(dx, dy); if (d == 0.0) { angle = 0.0; cos = 1.0; sin = 0.0; originOffset = p1.getY(); } else { angle = FastMath.PI + FastMath.atan2(-dy, -dx); cos = FastMath.cos(angle); sin = FastMath.sin(angle); originOffset = (p2.getX() * p1.getY() - p1.getX() * p2.getY()) / d; } }
Example 7
Source File: NPEfix_00172_t.java From coming with MIT License | 6 votes |
/** Reset the instance as if built from two points. * <p>The line is oriented from p1 to p2</p> * @param p1 first point * @param p2 second point */ public void reset(final Vector2D p1, final Vector2D p2) { final double dx = p2.getX() - p1.getX(); final double dy = p2.getY() - p1.getY(); final double d = FastMath.hypot(dx, dy); if (d == 0.0) { angle = 0.0; cos = 1.0; sin = 0.0; originOffset = p1.getY(); } else { angle = FastMath.PI + FastMath.atan2(-dy, -dx); cos = FastMath.cos(angle); sin = FastMath.sin(angle); originOffset = (p2.getX() * p1.getY() - p1.getX() * p2.getY()) / d; } }
Example 8
Source File: NPEfix_00170_t.java From coming with MIT License | 6 votes |
/** Reset the instance as if built from two points. * <p>The line is oriented from p1 to p2</p> * @param p1 first point * @param p2 second point */ public void reset(final Vector2D p1, final Vector2D p2) { final double dx = p2.getX() - p1.getX(); final double dy = p2.getY() - p1.getY(); final double d = FastMath.hypot(dx, dy); if (d == 0.0) { angle = 0.0; cos = 1.0; sin = 0.0; originOffset = p1.getY(); } else { angle = FastMath.PI + FastMath.atan2(-dy, -dx); cos = FastMath.cos(angle); sin = FastMath.sin(angle); originOffset = (p2.getX() * p1.getY() - p1.getX() * p2.getY()) / d; } }
Example 9
Source File: NPEfix_00171_s.java From coming with MIT License | 5 votes |
/** {@inheritDoc} */ public Line apply(final Hyperplane<Euclidean2D> hyperplane) { final Line line = (Line) hyperplane; final double rOffset = c1X * line.cos + c1Y * line.sin + c11 * line.originOffset; final double rCos = cXX * line.cos + cXY * line.sin; final double rSin = cYX * line.cos + cYY * line.sin; final double inv = 1.0 / FastMath.sqrt(rSin * rSin + rCos * rCos); return new Line(FastMath.PI + FastMath.atan2(-rSin, -rCos), inv * rCos, inv * rSin, inv * rOffset); }
Example 10
Source File: NPEfix_00174_s.java From coming with MIT License | 5 votes |
/** {@inheritDoc} */ public Line apply(final Hyperplane<Euclidean2D> hyperplane) { final Line line = (Line) hyperplane; final double rOffset = c1X * line.cos + c1Y * line.sin + c11 * line.originOffset; final double rCos = cXX * line.cos + cXY * line.sin; final double rSin = cYX * line.cos + cYY * line.sin; final double inv = 1.0 / FastMath.sqrt(rSin * rSin + rCos * rCos); return new Line(FastMath.PI + FastMath.atan2(-rSin, -rCos), inv * rCos, inv * rSin, inv * rOffset); }
Example 11
Source File: NPEfix_00171_t.java From coming with MIT License | 5 votes |
/** {@inheritDoc} */ public Line apply(final Hyperplane<Euclidean2D> hyperplane) { final Line line = (Line) hyperplane; final double rOffset = c1X * line.cos + c1Y * line.sin + c11 * line.originOffset; final double rCos = cXX * line.cos + cXY * line.sin; final double rSin = cYX * line.cos + cYY * line.sin; final double inv = 1.0 / FastMath.sqrt(rSin * rSin + rCos * rCos); return new Line(FastMath.PI + FastMath.atan2(-rSin, -rCos), inv * rCos, inv * rSin, inv * rOffset); }
Example 12
Source File: NPEfix_00172_s.java From coming with MIT License | 5 votes |
/** {@inheritDoc} */ public Line apply(final Hyperplane<Euclidean2D> hyperplane) { final Line line = (Line) hyperplane; final double rOffset = c1X * line.cos + c1Y * line.sin + c11 * line.originOffset; final double rCos = cXX * line.cos + cXY * line.sin; final double rSin = cYX * line.cos + cYY * line.sin; final double inv = 1.0 / FastMath.sqrt(rSin * rSin + rCos * rCos); return new Line(FastMath.PI + FastMath.atan2(-rSin, -rCos), inv * rCos, inv * rSin, inv * rOffset); }
Example 13
Source File: Atan2.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x, double y) { return FastMath.atan2(x, y); }
Example 14
Source File: Atan2.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x, double y) { return FastMath.atan2(x, y); }
Example 15
Source File: JGenProg2017_0026_s.java From coming with MIT License | 2 votes |
/** * Compute the argument of this complex number. * The argument is the angle phi between the positive real axis and * the point representing this number in the complex plane. * The value returned is between -PI (not inclusive) * and PI (inclusive), with negative values returned for numbers with * negative imaginary parts. * <br/> * If either real or imaginary part (or both) is NaN, NaN is returned. * Infinite parts are handled as {@code Math.atan2} handles them, * essentially treating finite parts as zero in the presence of an * infinite coordinate and returning a multiple of pi/4 depending on * the signs of the infinite parts. * See the javadoc for {@code Math.atan2} for full details. * * @return the argument of {@code this}. */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 16
Source File: Vector3D.java From astor with GNU General Public License v2.0 | 2 votes |
/** Get the azimuth of the vector. * @return azimuth (α) of the vector, between -π and +π * @see #Vector3D(double, double) */ public double getAlpha() { return FastMath.atan2(y, x); }
Example 17
Source File: Complex.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Compute the argument of this complex number. * The argument is the angle phi between the positive real axis and * the point representing this number in the complex plane. * The value returned is between -PI (not inclusive) * and PI (inclusive), with negative values returned for numbers with * negative imaginary parts. * <br/> * If either real or imaginary part (or both) is NaN, NaN is returned. * Infinite parts are handled as {@code Math.atan2} handles them, * essentially treating finite parts as zero in the presence of an * infinite coordinate and returning a multiple of pi/4 depending on * the signs of the infinite parts. * See the javadoc for {@code Math.atan2} for full details. * * @return the argument of {@code this}. */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 18
Source File: Elixir_0026_t.java From coming with MIT License | 2 votes |
/** * Compute the argument of this complex number. * The argument is the angle phi between the positive real axis and * the point representing this number in the complex plane. * The value returned is between -PI (not inclusive) * and PI (inclusive), with negative values returned for numbers with * negative imaginary parts. * <br/> * If either real or imaginary part (or both) is NaN, NaN is returned. * Infinite parts are handled as {@code Math.atan2} handles them, * essentially treating finite parts as zero in the presence of an * infinite coordinate and returning a multiple of pi/4 depending on * the signs of the infinite parts. * See the javadoc for {@code Math.atan2} for full details. * * @return the argument of {@code this}. */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 19
Source File: Circle.java From astor with GNU General Public License v2.0 | 2 votes |
/** Get the phase angle of a direction. * <p> * The direction may not belong to the circle as the * phase is computed for the meridian plane between the circle * pole and the direction. * </p> * @param direction direction for which phase is requested * @return phase angle of the direction around the circle * @see #toSubSpace(Point) */ public double getPhase(final Vector3D direction) { return FastMath.PI + FastMath.atan2(-direction.dotProduct(y), -direction.dotProduct(x)); }
Example 20
Source File: Complex.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Compute the argument of this complex number. * The argument is the angle phi between the positive real axis and * the point representing this number in the complex plane. * The value returned is between -PI (not inclusive) * and PI (inclusive), with negative values returned for numbers with * negative imaginary parts. * <br/> * If either real or imaginary part (or both) is NaN, NaN is returned. * Infinite parts are handled as {@code Math.atan2} handles them, * essentially treating finite parts as zero in the presence of an * infinite coordinate and returning a multiple of pi/4 depending on * the signs of the infinite parts. * See the javadoc for {@code Math.atan2} for full details. * * @return the argument of {@code this}. */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }