Java Code Examples for org.apache.commons.math.util.FastMath#atan2()
The following examples show how to use
org.apache.commons.math.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: HarmonicFitter.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Estimate a first guess of the phase. */ private void guessPhi() { // 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; } phi = FastMath.atan2(-fsMean, fcMean); }
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. */ private void guessPhi() { // 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; } phi = FastMath.atan2(-fsMean, fcMean); }
Example 4
Source File: Line.java From astor with GNU General Public License v2.0 | 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 5
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 6
Source File: Cardumen_00113_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 7
Source File: JGenProg2017_0065_s.java From coming with MIT License | 2 votes |
/** * <p>Compute the argument of this complex number. * </p> * <p>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. * </p> * <p>If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled * as java.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 java.Math.atan2 for full details.</p> * * @return the argument of this complex number */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 8
Source File: arja8_eigth_s.java From coming with MIT License | 2 votes |
/** * <p>Compute the argument of this complex number. * </p> * <p>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. * </p> * <p>If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled * as java.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 java.Math.atan2 for full details.</p> * * @return the argument of this complex number */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 9
Source File: JGenProg2017_0028_s.java From coming with MIT License | 2 votes |
/** * <p>Compute the argument of this complex number. * </p> * <p>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. * </p> * <p>If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled * as java.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 java.Math.atan2 for full details.</p> * * @return the argument of this complex number */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 10
Source File: Cardumen_0044_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 11
Source File: Cardumen_00262_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 12
Source File: Cardumen_00113_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 13
Source File: Cardumen_00218_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 14
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 15
Source File: Vector3D_t.java From coming with MIT License | 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 16
Source File: Complex_s.java From coming with MIT License | 2 votes |
/** * <p>Compute the argument of this complex number. * </p> * <p>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. * </p> * <p>If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled * as java.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 java.Math.atan2 for full details.</p> * * @return the argument of this complex number */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 17
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 18
Source File: Math_53_Complex_t.java From coming with MIT License | 2 votes |
/** * <p>Compute the argument of this complex number. * </p> * <p>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. * </p> * <p>If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled * as java.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 java.Math.atan2 for full details.</p> * * @return the argument of this complex number */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }
Example 19
Source File: Math_37_Complex_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 20
Source File: 1_Complex.java From SimFix with GNU General Public License v2.0 | 2 votes |
/** * <p>Compute the argument of this complex number. * </p> * <p>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. * </p> * <p>If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled * as java.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 java.Math.atan2 for full details.</p> * * @return the argument of this complex number */ public double getArgument() { return FastMath.atan2(getImaginary(), getReal()); }