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

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

Introduction

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

Prototype

public static double sin(double x) 

Source Link

Document

Sine function.

Usage

From source file:cc.redberry.core.number.ComplexUtils.java

/**
 * Numeric sine form complex number.//from w  w w  . ja v a  2  s.c o  m
 *
 * @param complex argument
 * @return sinus
 */
public static Complex sin(Complex complex) {
    if (complex.isReal())
        return new Complex(FastMath.sin(complex.getReal().doubleValue()));
    return new Complex(new org.apache.commons.math3.complex.Complex(complex.getReal().doubleValue(),
            complex.getImaginary().doubleValue()).sin());
}

From source file:com.tussle.main.Utility.java

public static double[] getXYfromDM(double direction, double magnitude) {
    double[] returnVect = new double[2];
    returnVect[0] = magnitude * FastMath.cos(FastMath.toRadians(direction));
    returnVect[1] = magnitude * FastMath.sin(FastMath.toDegrees(direction));
    return returnVect;
}

From source file:com.tussle.collision.CollisionCorner.java

public CollisionCorner(double x, double y, double min, double max) {
    this.x = x;/*from ww  w. j av  a 2 s. co m*/
    this.y = y;
    minVec = new ProjectionVector(FastMath.cos(FastMath.toRadians(min)), FastMath.sin(FastMath.toRadians(min)),
            1);
    maxVec = new ProjectionVector(FastMath.cos(FastMath.toRadians(max)), FastMath.sin(FastMath.toRadians(max)),
            1);
}

From source file:cloudnet.workloads.PeriodicWorkloadModel.java

@Override
protected double generateWorkload(long timestamp) {
    // workload = lower + diff_upper_lower * ((sin(x) + 1)/2 + deviation)
    double periodicValue = (FastMath.sin(timestamp * 2 * FastMath.PI / period) + 1) / 2;
    double randomValue = (2 * (random.nextDouble() - 0.5) * deviation);
    double workload = lowerThreshold + (upperThreshold - lowerThreshold) * (periodicValue + randomValue);
    return workload;
}

From source file:edu.unc.cs.gamma.rvo.Circle.java

private void setupScenario() {
    // Specify the global time step of the simulation.
    Simulator.instance.setTimeStep(0.25);

    // Specify the default parameters for agents that are subsequently
    // added./*  w  w w  . ja va  2  s . c  o m*/
    Simulator.instance.setAgentDefaults(15.0, 10, 10.0, 10.0, 1.5, 2.0, Vector2D.ZERO);

    // Add agents, specifying their start position, and store their goals on
    // the opposite side of the environment.
    final double angle = 0.008 * FastMath.PI;

    for (int i = 0; i < 250; i++) {
        Simulator.instance
                .addAgent(new Vector2D(FastMath.cos(i * angle), FastMath.sin(i * angle)).scalarMultiply(200.0));
        goals.add(Simulator.instance.getAgentPosition(i).negate());
    }
}

From source file:cloudnet.workloads.OnceInAlifetimeWorkloadModel.java

@Override
protected double generateWorkload(long timestamp) {
    // workload = baseValue, if timestamp <= startTime or timestamp > startTime + period /2
    // otherwise workload = periodic workload modelled with sin(x)
    if (timestamp >= startTime && timestamp < startTime + period / 2) {
        double periodicValue = FastMath.sin((timestamp - startTime) * 2 * FastMath.PI / period);
        double workload = baseValue + (peekValue - baseValue) * periodicValue;
        return workload;
    } else {/*ww w. ja  va 2 s.  c  o m*/
        return baseValue;
    }
}

From source file:gentracklets.conversions.java

public static double[] geo2radec(PVCoordinates obj, TopocentricFrame staF, Frame inertialFrame,
        AbsoluteDate epoch) {/* ww  w .  ja  va 2  s  .  c om*/

    Vector3D rho = new Vector3D(0, 0, 0);

    try {
        rho = obj.getPosition().subtract(staF.getPVCoordinates(epoch, inertialFrame).getPosition());
    } catch (OrekitException ex) {
        Logger.getLogger(conversions.class.getName()).log(Level.SEVERE, null, ex);
    }

    double rho_mag = rho.getNorm();
    double DEC = FastMath.asin(rho.getZ() / rho_mag);
    double cosRA = 0.0;
    double sinRA = 0.0;
    double RA = 0.0;

    Vector3D v_site = new Vector3D(0, 0, 0);
    try {
        v_site = staF.getPVCoordinates(epoch, inertialFrame).getVelocity();
    } catch (OrekitException ex) {
        Logger.getLogger(conversions.class.getName()).log(Level.SEVERE, null, ex);
    }

    Vector3D rhoDot = obj.getVelocity().subtract(v_site);

    if (FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2)) != 0) {
        cosRA = rho.getX() / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));
        sinRA = rho.getY() / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));
        RA = FastMath.atan2(sinRA, cosRA);
        if (RA <= 0) {
            RA = RA + 2 * FastMath.PI;
        }
    } else {
        sinRA = rhoDot.getY() / FastMath.sqrt(FastMath.pow(rhoDot.getX(), 2) + FastMath.pow(rhoDot.getY(), 2));
        cosRA = rhoDot.getX() / FastMath.sqrt(FastMath.pow(rhoDot.getX(), 2) + FastMath.pow(rhoDot.getY(), 2));
        RA = FastMath.atan2(sinRA, cosRA);
        if (RA <= 0) {
            RA = RA + 2 * FastMath.PI;
        }
    }

    double rhoDot_mag = rho.dotProduct(rhoDot) / rho_mag;
    double RAdot = (rhoDot.getX() * rho.getY() - rhoDot.getY() * rho.getX())
            / (-1 * FastMath.pow(rho.getY(), 2) - FastMath.pow(rho.getX(), 2));
    double DECdot = (rhoDot.getZ() - rhoDot_mag * FastMath.sin(DEC))
            / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));

    double[] out = { RA, RAdot, DEC, DECdot, rho_mag, rhoDot_mag };

    return out;
}

From source file:net.nicoulaj.benchmarks.math.DoubleSin.java

@GenerateMicroBenchmark
public void commonsmath(BlackHole hole) {
    for (int i = 0; i < data.length - 1; i++)
        hole.consume(FastMath.sin(data[i]));
}

From source file:lambertmrev.conversions.java

public static Vector3D radec2geo(Tracklet tracklet, double rho, TopocentricFrame staF, Frame inertialFrame,
        TimeScale utc) {/*from  w ww  . j a v a  2s .c o m*/

    double rho_k = rho * FastMath.sin(tracklet.getDEC());
    double rho_j = rho * FastMath.cos(tracklet.getDEC()) * FastMath.sin(tracklet.getRA());
    double rho_i = rho * FastMath.cos(tracklet.getDEC()) * FastMath.cos(tracklet.getRA());

    Vector3D rho_vec = new Vector3D(rho_i, rho_j, rho_k);
    //        System.out.println("rho used: " +  rho_vec);

    AbsoluteDate year = new AbsoluteDate(Main.YEAR, utc);
    AbsoluteDate epoch = new AbsoluteDate(year, tracklet.getDOY() * 24 * 3600);

    Vector3D out = new Vector3D(0, 0, 0);

    try {
        //            System.out.println("at epoch " + epoch + "\t the station is at: " + staF.getPVCoordinates(epoch, inertialFrame).getPosition());
        out = rho_vec.add(staF.getPVCoordinates(epoch, inertialFrame).getPosition());
    } catch (OrekitException e) {
        System.out.println("station coordinates not computed");
    }

    return out;
}

From source file:com.wwidesigner.geometry.calculation.DefaultFippleMouthpieceCalculator.java

@Override
protected TransferMatrix calcTransferMatrix(Mouthpiece mouthpiece, double waveNumber,
        PhysicalParameters parameters) {
    if (mouthpiece.isPressureNode()) {
        // Resort to default if this is not a flow-node mouthpiece.
        return super.calcTransferMatrix(mouthpiece, waveNumber, parameters);
    }//  w w  w  . j  av a 2s  .  co m
    // Use a simplified version of PhysicalParameters: no editable pressure
    // nor CO2 concentration. This mouthpiece representation gives very
    // wrong answers when they are varied.
    // The SimplePhysicalParameters gives correct answers for varying
    // temperature and humidity, all that a NAF maker is likely to measure.
    mParams = new SimplePhysicalParameters(parameters);

    double radius = 0.5 * mouthpiece.getBoreDiameter();
    double z0 = parameters.calcZ0(radius);
    double omega = waveNumber * parameters.getSpeedOfSound();
    double k_delta_l = calcKDeltaL(mouthpiece, omega, z0);
    // Add a series resistance for radiation loss.
    double r_rad = Tube.calcR(omega / (2 * Math.PI), radius, parameters);
    double cos_kl = FastMath.cos(k_delta_l);
    double sin_kl = FastMath.sin(k_delta_l);

    Complex A = new Complex(cos_kl, r_rad * sin_kl / z0);
    Complex B = new Complex(0., 1.).multiply(sin_kl * z0).add(r_rad * cos_kl);
    Complex C = new Complex(0., 1.).multiply(sin_kl / z0);
    Complex D = new Complex(cos_kl);
    return new TransferMatrix(A, B, C, D);
}