Example usage for java.lang Math sin

List of usage examples for java.lang Math sin

Introduction

In this page you can find the example usage for java.lang Math sin.

Prototype

@HotSpotIntrinsicCandidate
public static double sin(double a) 

Source Link

Document

Returns the trigonometric sine of an angle.

Usage

From source file:blue.soundObject.jmask.Oscillator.java

private double sin(double phpt) {
    return Math.sin(PI2 * phpt) * 0.5 + 0.5;
}

From source file:com.logicdrop.fordchallenge.api.services.IterisService.java

private double distanceFrom(List<String> item) {
    double lat = Double.parseDouble(item.get(0));
    double lng = Double.parseDouble(item.get(1));
    if (IncidentsActivity.getLocation() == null)
        return 0;
    double theta = lng - IncidentsActivity.getLocation().getLongitude();
    double distance = Math.sin(deg2rad(lat)) * Math.sin(deg2rad(IncidentsActivity.getLocation().getLatitude()))
            + Math.cos(deg2rad(lat)) * Math.cos(deg2rad(IncidentsActivity.getLocation().getLatitude()))
                    * Math.cos(deg2rad(theta));
    distance = Math.acos(distance);
    distance = Math.toDegrees(distance);
    distance = distance * 60 * 1.1515;//from w  ww  .  ja va  2s. c om
    return distance;
}

From source file:jat.core.cm.TwoBodyAPL.java

public double[] randv(double ta) {
    double p = a * (1.0 - e * e);
    double cta = Math.cos(ta);
    double sta = Math.sin(ta);
    double opecta = 1.0 + e * cta;
    double sqmuop = Math.sqrt(this.mu / p);

    VectorN xpqw = new VectorN(6);
    xpqw.x[0] = p * cta / opecta;/*from  w  w w .  j  av a  2  s . c o  m*/
    xpqw.x[1] = p * sta / opecta;
    xpqw.x[2] = 0.0;
    xpqw.x[3] = -sqmuop * sta;
    xpqw.x[4] = sqmuop * (e + cta);
    xpqw.x[5] = 0.0;

    Matrix cmat = PQW2ECI();

    VectorN rpqw = new VectorN(xpqw.x[0], xpqw.x[1], xpqw.x[2]);
    VectorN vpqw = new VectorN(xpqw.x[3], xpqw.x[4], xpqw.x[5]);

    VectorN rijk = cmat.times(rpqw);
    VectorN vijk = cmat.times(vpqw);

    double[] out = new double[6];

    for (int i = 0; i < 3; i++) {
        out[i] = rijk.x[i];
        out[i + 3] = vijk.x[i];
    }

    return out;
}

From source file:com.nextbreakpoint.nextfractal.mandelbrot.core.Expression.java

public static Number funcExp(MutableNumber out, Number x) {
    double d = Math.exp(x.r());
    return out.set(d * Math.cos(x.i()), d * Math.sin(x.i()));
}

From source file:com.opengamma.analytics.math.ComplexMathUtils.java

public static ComplexNumber pow(final ComplexNumber z, final double x) {
    final double mod = mod(z);
    final double arg = arg(z);
    final double mult = Math.pow(mod, x);
    return new ComplexNumber(mult * Math.cos(x * arg), mult * Math.sin(x * arg));
}

From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java

@Test
public void sinPi() {
    try {/*from   w w  w .jav  a  2 s.c  o m*/
        Expression expression = getExpressionWithFunctionContext("sin(pi)");
        assertEquals(ExpressionType.DOUBLE, expression.getExpressionType());
        assertEquals(Math.sin(Math.PI), expression.evaluateNumerical(), 1e-15);
    } catch (ExpressionException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:Main.java

static Node displacementMap() {
    int w = 220;/*from   w w w  .ja  v a2s .c  o m*/
    int h = 100;
    FloatMap map = new FloatMap();
    map.setWidth(w);
    map.setHeight(h);

    for (int i = 0; i < w; i++) {
        double v = (Math.sin(i / 50.0 * Math.PI) - 0.5) / 40.0;
        for (int j = 0; j < h; j++) {
            map.setSamples(i, j, 0.0f, (float) v);
        }
    }

    Group g = new Group();
    DisplacementMap dm = new DisplacementMap();
    dm.setMapData(map);

    Rectangle r = new Rectangle();
    r.setX(20.0f);
    r.setY(20.0f);
    r.setWidth(w);
    r.setHeight(h);
    r.setFill(Color.BLUE);

    g.getChildren().add(r);

    Text t = new Text();
    t.setX(40.0f);
    t.setY(80.0f);
    t.setText("Wavy Text");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font("null", FontWeight.BOLD, 36));

    g.getChildren().add(t);

    g.setEffect(dm);
    g.setCache(true);

    g.setTranslateX(400);
    g.setTranslateY(200);

    return g;
}

From source file:main.java.gov.wa.wsdot.candidate.evaluation.App.java

/**
 * Using the Haversine formula this method calculates the distance in miles
 * between two latitude and longitude points.
 * //  w  w w. j ava  2 s  .  c o m
 * Formula from: https://en.wikipedia.org/wiki/Haversine_formula
 * 
 * @param lat1  latitude of point 1 (user)
 * @param long1 longitude of point 1 (user)
 * @param lat2  latitude of point 2 (camera)
 * @param long2 longitude of point 2 (camera)
 * @return      distance in miles between two points given
 */
private double getDistance(double lat1, double long1, double lat2, double long2) {

    double deltaLong;
    double deltaLat;
    double hav2;
    double hav1;

    lat1 = Math.toRadians(lat1);
    lat2 = Math.toRadians(lat2);
    long1 = Math.toRadians(long1);
    long2 = Math.toRadians(long2);

    deltaLong = Math.toRadians(long2 - long1);
    deltaLat = Math.toRadians(lat2 - lat1);

    hav1 = (Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2));
    hav2 = (Math.sin(deltaLong / 2) * Math.sin(deltaLong / 2));

    return Math.toDegrees(2 * R * Math.asin(Math.sqrt(hav1 + Math.cos(lat1) * Math.cos(lat2) * hav2)));
}

From source file:msi.gama.common.geometry.Rotation3D.java

/**
 * Build a rotation from an axis and an angle.
 * /*www.j  a  v  a 2 s .  com*/
 * @param axis
 *            axis around which to rotate
 * @param angle
 *            rotation angle in radians
 */
public Rotation3D(final GamaPoint rotationAxis, final double angle) {
    GamaPoint axis = rotationAxis;
    if (axis == null) {
        axis = PLUS_K;
    }
    final double norm = axis.norm();

    final double halfAngle = -0.5 * angle;
    final double coeff = Math.sin(halfAngle) / norm;

    q0 = Math.cos(halfAngle);
    q1 = coeff * axis.x;
    q2 = coeff * axis.y;
    q3 = coeff * axis.z;

}

From source file:edu.uci.ics.jung.visualization.util.VertexShapeFactory.java

/**
 * Returns a regular <code>Polygon</code> of <code>num_points</code>
 * points whose bounding //from  www.ja  v  a  2  s  .c  o  m
 * box's width and height are defined by this instance's size and
 * aspect ratio functions for this vertex.
 * @param num_points the number of points of the polygon; must be >= 5.
 */
public Shape getRegularStar(V v, int num_points) {
    if (num_points < 5)
        throw new IllegalArgumentException("Number of sides must be >= 5");
    Rectangle2D frame = getRectangle(v);
    float width = (float) frame.getWidth();
    float height = (float) frame.getHeight();

    // generate coordinates
    double theta = (2 * Math.PI) / num_points;
    double angle = -theta / 2;
    thePolygon.reset();
    thePolygon.moveTo(0, 0);
    float delta_x = width * (float) Math.cos(angle);
    float delta_y = width * (float) Math.sin(angle);
    Point2D prev = thePolygon.getCurrentPoint();
    thePolygon.lineTo((float) prev.getX() + delta_x, (float) prev.getY() + delta_y);
    for (int i = 1; i < num_points; i++) {
        angle += theta;
        delta_x = width * (float) Math.cos(angle);
        delta_y = width * (float) Math.sin(angle);
        prev = thePolygon.getCurrentPoint();
        thePolygon.lineTo((float) prev.getX() + delta_x, (float) prev.getY() + delta_y);
        angle -= theta * 2;
        delta_x = width * (float) Math.cos(angle);
        delta_y = width * (float) Math.sin(angle);
        prev = thePolygon.getCurrentPoint();
        thePolygon.lineTo((float) prev.getX() + delta_x, (float) prev.getY() + delta_y);
    }
    thePolygon.closePath();

    // scale polygon to be right size, translate to center at (0,0)
    Rectangle2D r = thePolygon.getBounds2D();
    double scale_x = width / r.getWidth();
    double scale_y = height / r.getHeight();

    float translationX = (float) (r.getMinX() + r.getWidth() / 2);
    float translationY = (float) (r.getMinY() + r.getHeight() / 2);

    AffineTransform at = AffineTransform.getScaleInstance(scale_x, scale_y);
    at.translate(-translationX, -translationY);

    Shape shape = at.createTransformedShape(thePolygon);
    return shape;
}