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:BackEnd.E_old_calculation.java

private FazorVektor calc_DE(double tau_real, double tau_image, DPoint Rp, DPoint R0, DPoint R0m, DPoint deltaL)
        throws DelaunayError {
    DPoint R_0 = new DPoint(R0.getX(), R0.getY(), R0.getZ());
    DPoint R_0m = new DPoint(R0m.getX(), R0m.getY(), R0m.getZ());
    R_0.setY(R0.getY() + R0_bundleY); //  bundle korektura pre jeden druhy SMER 
    R_0.setZ(R0.getZ() + Math.cos(beta) * R0_bundleZ); // priemety
    R_0.setX(R0.getX() + Math.sin(beta) * R0_bundleZ);

    R_0m.setY(R0m.getY() - R0_bundleY); //  bundle korektura pre jeden druhy SMER 
    R_0m.setZ(R0m.getZ() + Math.cos(beta) * R0_bundleZ); // priemety
    R_0m.setX(R0m.getX() + Math.sin(beta) * R0_bundleZ);

    //  System.out.println( "R_0= " + R_0 );
    //  System.out.println( "Rp= " + Rp );
    // System.out.println( "deltal= " + deltaL );
    double K = 1 / (4 * Math.PI * constants.getEpsi0() * constants.getEpsi1()); // kontanta

    DPoint R_r = help.substract(Rp, R_0); // rozdiel vektorov Rp a RO
    DPoint R_m = help.substract(Rp, R_0m); // rozdiel vektorov RP a RO mirror
    DPoint R_r_unit = new DPoint(R_r);
    DPoint R_m_unit = new DPoint(R_m);

    //        R_r_unit.setX(R_r_unit.getX()/get_ABS(R_r));
    //        R_r_unit.setY(R_r_unit.getY()/get_ABS(R_r));
    //        R_r_unit.setZ(R_r_unit.getZ()/get_ABS(R_r));
    //        /* w w  w  . j a v a2  s .  c  o  m*/
    //        R_m_unit.setX(R_m_unit.getX()/get_ABS(R_m));
    //        R_m_unit.setY(R_m_unit.getY()/get_ABS(R_m));
    //        R_m_unit.setZ(R_m_unit.getZ()/get_ABS(R_m));

    double menovatel_r = 0;
    double menovatel_m = 0;

    menovatel_r = Math.pow(get_ABS(R_r), 3);
    menovatel_m = Math.pow(get_ABS(R_m), 3);

    double DELTA_l = get_ABS(deltaL);
    //
    //double DELTA_l = 1; //Rozptie.getKrok();

    FazorVektor deltaE = new FazorVektor(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));

    deltaE.setX_Real(K * (((tau_real * DELTA_l * R_r_unit.getX()) / menovatel_r)
            - ((tau_real * DELTA_l * R_m_unit.getX()) / menovatel_m)));
    deltaE.setY_Real(K * (((tau_real * DELTA_l * R_r_unit.getY()) / menovatel_r)
            - ((tau_real * DELTA_l * R_m_unit.getY()) / menovatel_m)));
    deltaE.setZ_Real(K * (((tau_real * DELTA_l * R_r_unit.getZ()) / menovatel_r)
            - ((tau_real * DELTA_l * R_m_unit.getZ()) / menovatel_m)));

    deltaE.setX_Imaginary(K * (((tau_image * DELTA_l * R_r_unit.getX()) / menovatel_r)
            - ((tau_image * DELTA_l * R_m_unit.getX()) / menovatel_m)));
    deltaE.setY_Imaginary(K * (((tau_image * DELTA_l * R_r_unit.getY()) / menovatel_r)
            - ((tau_image * DELTA_l * R_m_unit.getY()) / menovatel_m)));
    deltaE.setZ_Imaginary(K * (((tau_image * DELTA_l * R_r_unit.getZ()) / menovatel_r)
            - ((tau_image * DELTA_l * R_m_unit.getZ()) / menovatel_m)));

    return deltaE;
}

From source file:CircleLayoutTest.java

public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    int containerWidth = parent.getSize().width - insets.left - insets.right;
    int containerHeight = parent.getSize().height - insets.top - insets.bottom;
    int xradius = (containerWidth - maxComponentWidth) / 2;
    int yradius = (containerHeight - maxComponentHeight) / 2;

    setSizes(parent);/*from w  w w  . j a va2  s.  c  o m*/
    int centerX = insets.left + containerWidth / 2;
    int centerY = insets.top + containerHeight / 2;

    int comCount = parent.getComponentCount();
    for (int i = 0; i < comCount; i++) {
        Component c = parent.getComponent(i);
        if (c.isVisible()) {
            Dimension size = c.getPreferredSize();
            double angle = 2 * Math.PI * i / comCount;
            int x = centerX + (int) (Math.cos(angle) * xradius);
            int y = centerY + (int) (Math.sin(angle) * yradius);

            c.setBounds(x - size.width / 2, y - size.height / 2, size.width, size.height);
        }
    }
}

From source file:BackEnd.E_calculation.java

private FazorVektor calc_DE(double tau_real, double tau_image, DPoint Rp, DPoint R0, DPoint R0m, DPoint deltaL)
        throws DelaunayError {
    DPoint R_0 = new DPoint(R0.getX(), R0.getY(), R0.getZ());
    DPoint R_0m = new DPoint(R0.getX(), R0.getY(), R0.getZ());
    R_0.setY(R0.getY() + R0_bundleY); //  bundle korektura pre jeden druhy SMER 
    R_0.setZ(R0.getZ() + Math.cos(beta) * R0_bundleZ); // priemety
    R_0.setX(R0.getX() + Math.sin(beta) * R0_bundleZ);

    R_0m.setY(R0m.getY() - R0_bundleY); //  bundle korektura pre jeden druhy SMER 
    R_0m.setZ(R0m.getZ() + Math.cos(beta) * R0_bundleZ); // priemety
    R_0m.setX(R0m.getX() + Math.sin(beta) * R0_bundleZ);

    //  System.out.println( "R_0= " + R_0 );
    //  System.out.println( "Rp= " + Rp );
    // System.out.println( "deltal= " + deltaL );
    double K = 1 / (4 * Math.PI * constants.getEpsi0() * constants.getEpsi1()); // kontanta

    DPoint R_r = help.substract(Rp, R_0); // rozdiel vektorov Rp a RO
    DPoint R_m = help.substract(Rp, R_0m); // rozdiel vektorov RP a RO mirror
    DPoint R_r_unit = new DPoint(R_r);
    DPoint R_m_unit = new DPoint(R_m);

    R_r_unit.setX(R_r_unit.getX() / get_ABS(R_r));
    R_r_unit.setY(R_r_unit.getY() / get_ABS(R_r));
    R_r_unit.setZ(R_r_unit.getZ() / get_ABS(R_r));

    R_m_unit.setX(R_m_unit.getX() / get_ABS(R_m));
    R_m_unit.setY(R_m_unit.getY() / get_ABS(R_m));
    R_m_unit.setZ(R_m_unit.getZ() / get_ABS(R_m));

    double menovatel_r = Math.pow(get_ABS(R_r), 2);
    double menovatel_m = Math.pow(get_ABS(R_m), 2);
    double DELTA_l = get_ABS(deltaL);
    ////from   w  w w  . jav  a2 s .c o  m
    //double DELTA_l = 1; //Rozptie.getKrok();

    FazorVektor deltaE = new FazorVektor(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0));

    deltaE.setX_Real(K * (((tau_real * DELTA_l * R_r_unit.getX()) / menovatel_r)
            - ((tau_real * DELTA_l * R_m_unit.getX()) / menovatel_m)));
    deltaE.setY_Real(K * (((tau_real * DELTA_l * R_r_unit.getY()) / menovatel_r)
            - ((tau_real * DELTA_l * R_m_unit.getY()) / menovatel_m)));
    deltaE.setZ_Real(K * (((tau_real * DELTA_l * R_r_unit.getZ()) / menovatel_r)
            - ((tau_real * DELTA_l * R_m_unit.getZ()) / menovatel_m)));

    deltaE.setX_Imaginary(K * (((tau_image * DELTA_l * R_r_unit.getX()) / menovatel_r)
            - ((tau_image * DELTA_l * R_m_unit.getX()) / menovatel_m)));
    deltaE.setY_Imaginary(K * (((tau_image * DELTA_l * R_r_unit.getY()) / menovatel_r)
            - ((tau_image * DELTA_l * R_m_unit.getY()) / menovatel_m)));
    deltaE.setZ_Imaginary(K * (((tau_image * DELTA_l * R_r_unit.getZ()) / menovatel_r)
            - ((tau_image * DELTA_l * R_m_unit.getZ()) / menovatel_m)));

    return deltaE;
}

From source file:com.kentdisplays.synccardboarddemo.Page.java

/**
 * Sets up the drawing object data for use in an OpenGL ES context.
 *
 * @param is InputStream to the page to load the path data from.
 *//*w w  w. ja  v  a 2 s.  c o m*/
public Page(InputStream is, int glProgram, int direction) {

    this.mModel = new float[16];
    this.mGlProgram = glProgram;

    // Calculate the coordinates from the given path.
    ArrayList<Path> paths = pathsFromSamplePageInputStream(is);
    float finalCoords[] = {};
    float finalNormals[] = {};
    float finalColors[] = {};
    mNumberOfPaths = paths.size();
    for (int i = 0; i < mNumberOfPaths; i++) {
        Path path = paths.get(i);
        float x1 = (path.x1 / 13942 * 2) - 1;
        float y1 = (path.y1 / 20280 * 2) - 1;
        float x2 = (path.x2 / 13942 * 2) - 1;
        float y2 = (path.y2 / 20280 * 2) - 1;
        float width = path.width / 3000;
        width = width < 0.013f ? 0.013f : width; // Width should be at least 0.013

        float distance = (float) Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
        float angle = (float) Math.PI / 2 - (float) Math.asin((x2 - x1) / distance);
        float xdiff = (width / 2) * (float) Math.sin(angle);
        float ydiff = (width / 2) * (float) Math.cos(angle);

        float coords[] = { x1 - xdiff, y1 - ydiff, 1.0f, // top left
                x2 - xdiff, y2 - ydiff, 1.0f, // bottom left
                x1 + xdiff, y1 + ydiff, 1.0f, // top right
                x2 - xdiff, y2 - ydiff, 1.0f, // bottom left
                x2 + xdiff, y2 + ydiff, 1.0f, // bottom right
                x1 + xdiff, y1 + ydiff, 1.0f, // top right
        };

        float normals[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
                1.0f, 0.0f, 0.0f, 1.0f, };

        float colors[] = { 0.2f, 0.709803922f, 0.898039216f, 1.0f, 0.2f, 0.709803922f, 0.898039216f, 1.0f, 0.2f,
                0.709803922f, 0.898039216f, 1.0f, 0.2f, 0.709803922f, 0.898039216f, 1.0f, 0.2f, 0.709803922f,
                0.898039216f, 1.0f, 0.2f, 0.709803922f, 0.898039216f, 1.0f, };

        finalCoords = Floats.concat(finalCoords, coords);
        finalNormals = Floats.concat(finalNormals, normals);
        finalColors = Floats.concat(finalColors, colors);
    }

    ByteBuffer bbVertices = ByteBuffer.allocateDirect(finalCoords.length * 4);
    bbVertices.order(ByteOrder.nativeOrder());
    mPageVertices = bbVertices.asFloatBuffer();
    mPageVertices.put(finalCoords);
    mPageVertices.position(0);

    ByteBuffer bbNormals = ByteBuffer.allocateDirect(finalNormals.length * 4);
    bbNormals.order(ByteOrder.nativeOrder());
    mPageNormals = bbNormals.asFloatBuffer();
    mPageNormals.put(finalNormals);
    mPageNormals.position(0);

    ByteBuffer bbColors = ByteBuffer.allocateDirect(finalColors.length * 4);
    bbColors.order(ByteOrder.nativeOrder());
    mPageColors = bbColors.asFloatBuffer();
    mPageColors.put(finalColors);
    mPageColors.position(0);

    // Correctly place the page in the world.
    Matrix.setIdentityM(mModel, 0);
    switch (direction) {
    case 0:
        Matrix.translateM(mModel, 0, 0, 0, -mDistance); //Front.
        break;
    case 1:
        Matrix.translateM(mModel, 0, -mDistance, 0, 0); // Left.
        Matrix.rotateM(mModel, 0, 90, 0, 1f, 0);
        break;
    case 2:
        Matrix.translateM(mModel, 0, 0, 0, mDistance); // Behind.
        Matrix.rotateM(mModel, 0, 180, 0, 1f, 0);
        break;
    case 3:
        Matrix.translateM(mModel, 0, mDistance, 0, 0); // Right.
        Matrix.rotateM(mModel, 0, 270, 0, 1f, 0);
        break;
    }
}

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

@Test
public void sinDouble() {
    try {//from  w  w w.ja  v  a  2  s  .co  m
        Expression expression = getExpressionWithFunctionContext("sin(33.3)");
        assertEquals(ExpressionType.DOUBLE, expression.getExpressionType());
        assertEquals(Math.sin(33.3), expression.evaluateNumerical(), 1e-15);
    } catch (ExpressionException e) {
        assertNotNull(e.getMessage());
    }
}

From source file:Randoms.java

/** Return a random double drawn from a Gaussian distribution with mean 0 and variance 1. */
public synchronized double nextGaussian() {
    if (!haveNextGaussian) {
        double v1 = nextUniform(), v2 = nextUniform();
        double x1, x2;
        x1 = Math.sqrt(-2 * Math.log(v1)) * Math.cos(2 * Math.PI * v2);
        x2 = Math.sqrt(-2 * Math.log(v1)) * Math.sin(2 * Math.PI * v2);
        nextGaussian = x2;/*from  ww w.  ja  v a 2s.  c  o m*/
        haveNextGaussian = true;
        return x1;
    } else {
        haveNextGaussian = false;
        return nextGaussian;
    }
}

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

public static ComplexNumber sinh(final ComplexNumber z) {
    Validate.notNull(z, "z");
    return new ComplexNumber(Math.sinh(z.getReal()) * Math.cos(z.getImaginary()),
            Math.cosh(z.getReal()) * Math.sin(z.getImaginary()));
}

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

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

From source file:info.raack.appliancedetection.evaluation.model.appliance.SineWaveDevice.java

protected int powerDrawAtOnCycleTimestep(int totalSeconds, int secondIndex, int globalTimestep) {
    return (int) (Math.sin((2 * Math.PI) * (float) secondIndex / wavelength) * maxAmplitude)
            + (int) Math.ceil(maxAmplitude);
}

From source file:com.alvermont.terraj.planet.project.HeightfieldGenerator.java

/**
 * Generate the heightfield data/*from   ww w  .  j a  va2  s.  c om*/
 */
public void generate() {
    final int width = getParameters().getProjectionParameters().getWidth();

    final int height = getParameters().getProjectionParameters().getHeight();

    final double lat = getParameters().getProjectionParameters().getLatitudeRadians();

    final double lon = getParameters().getProjectionParameters().getLongitudeRadians();

    final double scale = getParameters().getProjectionParameters().getScale();

    heights = new int[width][height];

    final double sla = Math.sin(lat);
    final double cla = Math.cos(lat);
    final double slo = Math.sin(lon);
    final double clo = Math.cos(lon);

    cacheParameters();

    depth = (3 * ((int) (log2(scale * height)))) + 6;

    double x;
    double y;
    double z;
    double x1;
    double y1;
    double z1;

    for (int j = 0; j < height; ++j) {
        for (int i = 0; i < width; ++i) {
            x = ((2.0 * i) - width) / height / scale;
            y = ((2.0 * j) - height) / height / scale;

            if (((x * x) + (y * y)) > 1.0) {
                heights[i][j] = 0;
            } else {
                z = Math.sqrt(1.0 - (x * x) - (y * y));

                x1 = (clo * x) + (slo * sla * y) + (slo * cla * z);
                y1 = (cla * y) - (sla * z);
                z1 = (-slo * x) + (clo * sla * y) + (clo * cla * z);

                final double heightValue = planet1(x1, y1, z1);

                heights[i][j] = (int) (10000000.0 * heightValue);
            }
        }
    }
}