Example usage for org.apache.commons.math.util FastMath sin

List of usage examples for org.apache.commons.math.util FastMath sin

Introduction

In this page you can find the example usage for org.apache.commons.math.util FastMath sin.

Prototype

public static double sin(double x) 

Source Link

Document

Sine function.

Usage

From source file:org.esa.nest.gpf.ALOSDeskewingOp.java

private boolean getLook(final stateVector v, final double slant, final double yaw, final double[] plook) {

    final GeoCoding geoCoding = sourceProduct.getGeoCoding();
    if (geoCoding == null) {
        throw new OperatorException("GeoCoding is null");
    }//from  w  ww.  j  av  a 2 s . co m

    final GeoPos geoPos = geoCoding.getGeoPos(new PixelPos(0, 0), null);
    final double earthRadius = computeEarthRadius(geoPos);

    final double ht = Math.sqrt(v.xPos * v.xPos + v.yPos * v.yPos + v.zPos * v.zPos);

    double look = FastMath.acos((ht * ht + slant * slant - earthRadius * earthRadius) / (2.0 * slant * ht));

    for (int iter = 0; iter < 100; iter++) {

        double delta_range = slant - calcRange(v, look, yaw);
        if (Math.abs(delta_range) < 0.1) {
            plook[0] = look;
            return true;
        } else {
            double sininc = (ht / earthRadius) * FastMath.sin(look);
            double taninc = sininc / Math.sqrt(1 - sininc * sininc);
            look += delta_range / (slant * taninc);
        }
    }

    return false;
}

From source file:org.esa.nest.gpf.ALOSDeskewingOp.java

private static double calcRange(final stateVector v, final double look, final double yaw) {

    final double[][] rM = new double[3][3];
    getRotationMatrix(v, rM);// www.  j  a  v a  2s.  c  om

    final double cosyaw = FastMath.cos(yaw);
    final double x = FastMath.sin(yaw);
    final double y = -FastMath.sin(look) * cosyaw;
    final double z = -FastMath.cos(look) * cosyaw;

    final double rx = rM[0][0] * x + rM[1][0] * y + rM[2][0] * z;
    final double ry = rM[0][1] * x + rM[1][1] * y + rM[2][1] * z;
    final double rz = rM[0][2] * x + rM[1][2] * y + rM[2][2] * z;

    final double re = GeoUtils.WGS84.a;
    final double rp = re - re / GeoUtils.WGS84.b;
    final double re2 = re * re;
    final double rp2 = rp * rp;
    final double a = (rx * rx + ry * ry) / re2 + rz * rz / rp2;
    final double b = 2.0 * ((v.xPos * rx + v.yPos * ry) / re2 + v.zPos * rz / rp2);
    final double c = (v.xPos * v.xPos + v.yPos * v.yPos) / re2 + v.zPos * v.zPos / rp2 - 1.0;

    final double d = (b * b - 4.0 * a * c);
    if (d < 0) {
        return -1.0;
    }

    final double sqrtD = Math.sqrt(d);
    final double ans1 = (-b + sqrtD) / (2.0 * a);
    final double ans2 = (-b - sqrtD) / (2.0 * a);

    return Math.min(ans1, ans2);
}

From source file:org.esa.nest.gpf.ALOSDeskewingOp.java

private static double getDoppler(final stateVector v, final double look, final double yaw,
        final double[] relVel, final double lambda) {

    final double spx = v.xPos, spy = v.yPos, spz = v.zPos;
    final double svx = v.xVel, svy = v.yVel, svz = v.zVel;

    final double x = FastMath.sin(yaw);
    final double y = -FastMath.sin(look) * FastMath.cos(yaw);
    final double z = -FastMath.cos(look) * FastMath.cos(yaw);

    final double[][] rM = new double[3][3];
    getRotationMatrix(v, rM);/*from ww  w.  java  2s  .  c  o  m*/

    double rpx = rM[0][0] * x + rM[1][0] * y + rM[2][0] * z;
    double rpy = rM[0][1] * x + rM[1][1] * y + rM[2][1] * z;
    double rpz = rM[0][2] * x + rM[1][2] * y + rM[2][2] * z;

    final double range = calcRange(v, look, yaw);

    rpx *= range;
    rpy *= range;
    rpz *= range;

    final double tpx = rpx + spx;
    final double tpy = rpy + spy;
    final double tpz = rpz + spz;

    final double tvx = -AngularVelocity * tpy;
    final double tvy = AngularVelocity * tpx;
    final double tvz = 0.0;

    final double rvx = tvx - svx;
    final double rvy = tvy - svy;
    final double rvz = tvz - svz;

    relVel[0] = rvx;
    relVel[1] = rvy;
    relVel[2] = rvz;

    return -2.0 / (lambda * range) * (rpx * rvx + rpy * rvy + rpz * rvz);
}

From source file:org.esa.nest.gpf.ALOSDeskewingOp.java

/**
 * Compute Earth radius for pixel at (0,0).
 * @param geoPos lat lon position//from w w  w.  java 2  s  . c o  m
 * @return The Earth radius.
 */
private static double computeEarthRadius(final GeoPos geoPos) {

    final double lat = geoPos.lat;
    final double re = Constants.semiMajorAxis;
    final double rp = Constants.semiMinorAxis;
    return (re * rp) / Math.sqrt(
            rp * rp * FastMath.cos(lat) * FastMath.cos(lat) + re * re * FastMath.sin(lat) * FastMath.sin(lat));
}

From source file:org.esa.nest.gpf.SARSimulationOp.java

/**
 * Compute backscattered power for a given local incidence angle.
 * @param localIncidenceAngle The local incidence angle (in degree).
 * @return The backscattered power.//from ww  w.  j  a  v  a2  s . com
 */
private static double computeBackscatteredPower(final double localIncidenceAngle) {
    final double alpha = localIncidenceAngle * org.esa.beam.util.math.MathUtils.DTOR;
    final double cosAlpha = FastMath.cos(alpha);
    return (0.0118 * cosAlpha / Math.pow(FastMath.sin(alpha) + 0.111 * cosAlpha, 3));
}

From source file:org.esa.nest.util.MathUtils.java

/**
 * The sinc function.//  ww w.ja v  a 2s.  c o  m
 * @param x The input variable.
 * @return The sinc function value.
 */
private static double sinc(final double x) {

    if (Double.compare(x, 0.0) == 0) {
        return 1.0;
    } else {
        return FastMath.sin(x * Math.PI) / (x * Math.PI);
    }
}