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:geogebra.util.MyMath.java

final public static double csc(double a) {
    return 1 / Math.sin(a);
}

From source file:ai.grakn.graql.internal.shell.animalia.chordata.mammalia.artiodactyla.hippopotamidae.HippopotamusFactory.java

/**
 * Raise population of hippopotamus amphibius within console.
 * @param console//from  w  ww .  j av  a2s .c  o m
 */
public static void increasePop(ConsoleReader console) {
    HippopotamusFactory builder = HippopotamusFactory.builder();

    if (System.getenv("HIPPO_SIZE") != null) {
        int hippoSize = Integer.parseInt(System.getenv("HIPPO_SIZE"));
        builder.size(hippoSize);
    }

    Hippopotamus hippo = builder.build();

    try {
        for (double i = 0; i < Math.PI; i += 0.1) {
            console.println(hippo.toString().replaceAll("^|\n",
                    "\n" + StringUtils.repeat(" ", (int) (Math.sin(i) * 100))));
            console.flush();
            Thread.sleep(100);
        }
    } catch (IOException | InterruptedException e) {
        System.err.println("Supercalafrajilistichippopotamusexception");
    }

    hippo.submerge();

    console.setPrompt(hippo.toString());
}

From source file:com.hurence.tmp.FFT.java

public static Complex[] fft(Complex[] x) {
    int N = x.length;

    // base case/*from w  w  w.j a  v  a  2 s .co m*/
    if (N == 1) {
        return new Complex[] { x[0] };
    }

    // radix 2 Cooley-Tukey FFT
    if (N % 2 != 0) {
        throw new RuntimeException("N is not a power of 2");
    }

    // fft of even terms
    Complex[] even = new Complex[N / 2];
    for (int k = 0; k < N / 2; k++) {
        even[k] = x[2 * k];
    }
    Complex[] q = fft(even);

    // fft of odd terms
    Complex[] odd = even; // reuse the array
    for (int k = 0; k < N / 2; k++) {
        odd[k] = x[2 * k + 1];
    }
    Complex[] r = fft(odd);

    // combine
    Complex[] y = new Complex[N];
    for (int k = 0; k < N / 2; k++) {
        double kth = -2 * k * Math.PI / N;
        Complex wk = new Complex(Math.cos(kth), Math.sin(kth));
        y[k] = q[k].add(wk.multiply(r[k]));
        y[k + N / 2] = q[k].subtract(wk.multiply(r[k]));
    }
    return y;
}

From source file:de.termininistic.serein.examples.benchmarks.functions.multimodal.SchwefelFunction.java

@Override
public double map(RealVector v) {
    double[] x = v.toArray();
    int n = x.length;
    double fx = 418.9829 * n;
    for (int i = 0; i < n; i++) {
        fx += -x[i] * Math.sin((Math.sqrt(Math.abs(x[i]))));
    }//w  ww .  j  a va2 s  . c  o m
    return fx;
}

From source file:IK.G.java

public static double sin(double in) {
    return Math.sin(in);
}

From source file:Main.java

public static double transformlat(double lng, double lat) {
    double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat
            + 0.2 * Math.sqrt(Math.abs(lng));
    ret += (20.0 * Math.sin(6.0 * lng * pi) + 20.0 * Math.sin(2.0 * lng * pi)) * 2.0 / 3.0;
    ret += (20.0 * Math.sin(lat * pi) + 40.0 * Math.sin(lat / 3.0 * pi)) * 2.0 / 3.0;
    ret += (160.0 * Math.sin(lat / 12.0 * pi) + 320 * Math.sin(lat * pi / 30.0)) * 2.0 / 3.0;
    return ret;/* ww w .  j  a  v a 2s .c o  m*/
}

From source file:fsm.series.Series_SS.java

@Override
public double getSecondDerivativeValue(double y, int m) {
    return -Math.sin(m * Math.PI * y / a) * (m * Math.PI / a) * (m * Math.PI / a);
}

From source file:geogebra.util.MyMath.java

final public static double cot(double a) {
    return Math.cos(a) / Math.sin(a);
}

From source file:Main.java

private static BufferedImage createRotatedImage(Object src, int width, int height, int angle) {
    angle = angle % 360;/*from w  w  w  .j  ava2  s  .c  o  m*/

    if (angle < 0) {
        angle += 360;
    }

    if (angle == 0) {
        return renderRotatedObject(src, 0, width, height, 0, 0);
    } else if (angle == 90) {
        return renderRotatedObject(src, -Math.PI / 2, height, width, -width, 0);
    } else if (angle == 180) {
        return renderRotatedObject(src, Math.PI, width, height, -width, -height);
    } else if (angle == 270) {
        return renderRotatedObject(src, Math.PI / 2, height, width, 0, -height);
    } else if (angle > 0 && angle < 90) {
        double angleInRadians = ((-angle * Math.PI) / 180.0);
        double cosTheta = Math.abs(Math.cos(angleInRadians));
        double sineTheta = Math.abs(Math.sin(angleInRadians));

        int dW = (int) (width * cosTheta + height * sineTheta);
        int dH = (int) (width * sineTheta + height * cosTheta);

        return renderRotatedObject(src, angleInRadians, dW, dH, -width * sineTheta * sineTheta,
                width * sineTheta * cosTheta);

    } else if (angle > 90 && angle < 180) {
        double angleInRadians = ((-angle * Math.PI) / 180.0);
        double cosTheta = Math.abs(Math.cos(angleInRadians));
        double sineTheta = Math.abs(Math.sin(angleInRadians));

        int dW = (int) (width * cosTheta + height * sineTheta);
        int dH = (int) (width * sineTheta + height * cosTheta);

        return renderRotatedObject(src, angleInRadians, dW, dH, -(width + height * sineTheta * cosTheta),
                -height / 2);

    } else if (angle > 180 && angle < 270) {
        double angleInRadians = ((-angle * Math.PI) / 180.0);
        double cosTheta = Math.abs(Math.cos(angleInRadians));
        double sineTheta = Math.abs(Math.sin(angleInRadians));

        int dW = (int) (width * cosTheta + height * sineTheta);
        int dH = (int) (width * sineTheta + height * cosTheta);

        return renderRotatedObject(src, angleInRadians, dW, dH, -(width * cosTheta * cosTheta),
                -(height + width * cosTheta * sineTheta));

    } else if (angle > 270 && angle < 360) {
        double angleInRadians = ((-angle * Math.PI) / 180.0);
        double cosTheta = Math.abs(Math.cos(angleInRadians));
        double sineTheta = Math.abs(Math.sin(angleInRadians));

        int dW = (int) (width * cosTheta + height * sineTheta);
        int dH = (int) (width * sineTheta + height * cosTheta);

        return renderRotatedObject(src, angleInRadians, dW, dH, (height * cosTheta * sineTheta),
                -(height * sineTheta * sineTheta));

    }

    return renderRotatedObject(src, 0, width, height, 0, 0);
}

From source file:de.tuberlin.uebb.jdae.diff.partial.PDOperations.java

public final void sin(final double[] values, final double[] target) {
    compose(Math.sin(values[0]), Math.cos(values[0]), values, target);
}