当前位置: 首页>>代码示例>>Java>>正文


Java FastMath.atan2方法代码示例

本文整理汇总了Java中org.apache.commons.math3.util.FastMath.atan2方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.atan2方法的具体用法?Java FastMath.atan2怎么用?Java FastMath.atan2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.util.FastMath的用法示例。


在下文中一共展示了FastMath.atan2方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: guessPhi

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:31,代码来源:HarmonicFitter.java

示例2: reset

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** 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) {
    unlinkReverse();
    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          = dx / d;
        sin          = dy / d;
        originOffset = MathArrays.linearCombination(p2.getX(), p1.getY(), -p1.getX(), p2.getY()) / d;
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:23,代码来源:Line.java

示例3: convexCellArea

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Compute convex cell area.
 * @param start start vertex of the convex cell boundary
 * @return area
 */
private double convexCellArea(final Vertex start) {

    int n = 0;
    double sum = 0;

    // loop around the cell
    for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {

        // find path interior angle at vertex
        final Vector3D previousPole = e.getCircle().getPole();
        final Vector3D nextPole     = e.getEnd().getOutgoing().getCircle().getPole();
        final Vector3D point        = e.getEnd().getLocation().getVector();
        double alpha = FastMath.atan2(Vector3D.dotProduct(nextPole, Vector3D.crossProduct(point, previousPole)),
                                      -Vector3D.dotProduct(nextPole, previousPole));
        if (alpha < 0) {
            alpha += MathUtils.TWO_PI;
        }
        sum += alpha;
        n++;
    }

    // compute area using extended Girard theorem
    // see Spherical Trigonometry: For the Use of Colleges and Schools by I. Todhunter
    // article 99 in chapter VIII Area Of a Spherical Triangle. Spherical Excess.
    // book available from project Gutenberg at http://www.gutenberg.org/ebooks/19770
    return sum - (n - 2) * FastMath.PI;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:33,代码来源:PropertiesComputer.java

示例4: apply

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public Line apply(final Hyperplane<Euclidean2D> hyperplane) {
    final Line   line    = (Line) hyperplane;
    final double rOffset = MathArrays.linearCombination(c1X, line.cos, c1Y, line.sin, c11, line.originOffset);
    final double rCos    = MathArrays.linearCombination(cXX, line.cos, cXY, line.sin);
    final double rSin    = MathArrays.linearCombination(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, line.tolerance);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:12,代码来源:Line.java

示例5: value

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double value(double x, double y) {
    return FastMath.atan2(x, y);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:5,代码来源:Atan2.java

示例6: atan2

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public SparseGradient atan2(final SparseGradient x) {

    // compute r = sqrt(x^2+y^2)
    final SparseGradient r = multiply(this).add(x.multiply(x)).sqrt();

    final SparseGradient a;
    if (x.value >= 0) {

        // compute atan2(y, x) = 2 atan(y / (r + x))
        a = divide(r.add(x)).atan().multiply(2);

    } else {

        // compute atan2(y, x) = +/- pi - 2 atan(y / (r - x))
        final SparseGradient tmp = divide(r.subtract(x)).atan().multiply(-2);
        a = tmp.add(tmp.value <= 0 ? -FastMath.PI : FastMath.PI);

    }

    // fix value to take special cases (+0/+0, +0/-0, -0/+0, -0/-0, +/-infinity) correctly
    a.value = FastMath.atan2(value, x.value);

    return a;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:SparseGradient.java

示例7: atan2

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Compute two arguments arc tangent of a derivative structure.
 * @param y array holding the first operand
 * @param yOffset offset of the first operand in its array
 * @param x array holding the second operand
 * @param xOffset offset of the second operand in its array
 * @param result array where result must be stored (for
 * two arguments arc tangent the result array <em>cannot</em>
 * be the input array)
 * @param resultOffset offset of the result in its array
 */
public void atan2(final double[] y, final int yOffset,
                  final double[] x, final int xOffset,
                  final double[] result, final int resultOffset) {

    // compute r = sqrt(x^2+y^2)
    double[] tmp1 = new double[getSize()];
    multiply(x, xOffset, x, xOffset, tmp1, 0);      // x^2
    double[] tmp2 = new double[getSize()];
    multiply(y, yOffset, y, yOffset, tmp2, 0);      // y^2
    add(tmp1, 0, tmp2, 0, tmp2, 0);                 // x^2 + y^2
    rootN(tmp2, 0, 2, tmp1, 0);                     // r = sqrt(x^2 + y^2)

    if (x[xOffset] >= 0) {

        // compute atan2(y, x) = 2 atan(y / (r + x))
        add(tmp1, 0, x, xOffset, tmp2, 0);          // r + x
        divide(y, yOffset, tmp2, 0, tmp1, 0);       // y /(r + x)
        atan(tmp1, 0, tmp2, 0);                     // atan(y / (r + x))
        for (int i = 0; i < tmp2.length; ++i) {
            result[resultOffset + i] = 2 * tmp2[i]; // 2 * atan(y / (r + x))
        }

    } else {

        // compute atan2(y, x) = +/- pi - 2 atan(y / (r - x))
        subtract(tmp1, 0, x, xOffset, tmp2, 0);     // r - x
        divide(y, yOffset, tmp2, 0, tmp1, 0);       // y /(r - x)
        atan(tmp1, 0, tmp2, 0);                     // atan(y / (r - x))
        result[resultOffset] =
                ((tmp2[0] <= 0) ? -FastMath.PI : FastMath.PI) - 2 * tmp2[0]; // +/-pi - 2 * atan(y / (r - x))
        for (int i = 1; i < tmp2.length; ++i) {
            result[resultOffset + i] = -2 * tmp2[i]; // +/-pi - 2 * atan(y / (r - x))
        }

    }

    // fix value to take special cases (+0/+0, +0/-0, -0/+0, -0/-0, +/-infinity) correctly
    result[resultOffset] = FastMath.atan2(y[yOffset], x[xOffset]);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:51,代码来源:DSCompiler.java

示例8: getPhase

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** 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));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:14,代码来源:Circle.java

示例9: S2Point

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Simple constructor.
 * Build a vector from its underlying 3D vector
 * @param vector 3D vector
 * @exception MathArithmeticException if vector norm is zero
 */
public S2Point(final Vector3D vector) throws MathArithmeticException {
    this(FastMath.atan2(vector.getY(), vector.getX()), Vector3D.angle(Vector3D.PLUS_K, vector),
         vector.normalize());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:10,代码来源:S2Point.java

示例10: getAlpha

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Get the azimuth of the vector.
 * @return azimuth (&alpha;) of the vector, between -&pi; and +&pi;
 * @see #Vector3D(double, double)
 */
public double getAlpha() {
    return FastMath.atan2(y, x);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:8,代码来源:Vector3D.java

示例11: getArgument

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
 * 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.
 * <p>
 * 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());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:21,代码来源:Complex.java


注:本文中的org.apache.commons.math3.util.FastMath.atan2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。