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:electrical_parameters.Carson.java

public void calcXg() {
    //        this.Xg = this.Dik.copy();
    //        this.Xg = clearMatrix(this.Xg);
    double[] b;/* w ww  .  j ava  2s .  c  om*/
    double[] c;
    double[] d;
    double kik_xg;
    double fik;

    b = b();
    c = c();
    d = d();
    calckik();

    for (int i = 0; i < this.kik.getRowDimension(); i++) {
        for (int j = 0; j < this.kik.getColumnDimension(); j++) {
            fik = this.Fik.getEntry(i, j);
            kik_xg = this.kik.getEntry(i, j);
            this.Xg.setEntry(i, j, (4e-4) * omega * (((double) 1 / 2) * (0.6159315 - Math.log(kik_xg))
                    + b[0] * kik_xg * Math.cos(fik) - d[1] * pow(kik_xg, 2) * Math.cos(2 * fik)
                    + b[2] * pow(kik_xg, 3) * Math.cos(3 * fik)
                    - b[3] * ((c[3] - Math.log(kik_xg)) * pow(kik_xg, 4) * Math.cos(4 * fik)
                            + fik * pow(kik_xg, 4) * Math.sin(4 * fik))
                    + b[4] * kik_xg * Math.cos(fik) - d[5] * pow(kik_xg, 2) * Math.cos(2 * fik)
                    + b[6] * pow(kik_xg, 3) * Math.cos(3 * fik)
                    - b[7] * ((c[7] - Math.log(kik_xg)) * pow(kik_xg, 4) * Math.cos(4 * fik)
                            + fik * pow(kik_xg, 4) * Math.sin(4 * fik))));
        }
    }
}

From source file:interfaceTisseoWS.ST3.java

public double getDistance(double x1, double y1, double x2, double y2) {
    double d2r = Math.PI / 180;

    try {/* w w  w .j  a  va  2 s . co  m*/
        double dlong = (x2 - x1) * d2r;
        double dlat = (y2 - y1) * d2r;
        double a = Math.pow(Math.sin(dlat / 2.0), 2)
                + Math.cos(y1 * d2r) * Math.cos(y2 * d2r) * Math.pow(Math.sin(dlong / 2.0), 2);
        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        double d = 6367 * c;

        return d;

    } catch (Exception e) {
    }
    return -1.0;
}

From source file:fsm.series.Series_CC.java

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

From source file:com.alvermont.terraj.planet.PlanetGen.java

/**
 * Carries out the remaining levels of terrain generation, recursivel
 * until the last level is reached. Returns the height of the planet
 * at this point/*w ww  .  j a  v  a  2s .  co  m*/
 *
 * @param a Altitude of vertex 1
 * @param b Altitude of vertex 2
 * @param c Altitude of vertex 3
 * @param d Altitude of vertex 4
 * @param as Seed of vertex 1
 * @param bs Seed of vertex 2
 * @param cs Seed of vertex 3
 * @param ds Seed of vertex 4
 * @param ax Vertex 1 X coordinate
 * @param ay Vertex 1 Y coordinate
 * @param az Vertex 1 Z coordinate
 * @param bx Vertex 2 X coordinate
 * @param by Vertex 2 Y coordinate
 * @param bz Vertex 2 Z coordinate
 * @param cx Vertex 3 X coordinate
 * @param cy Vertex 3 Y coordinate
 * @param cz Vertex 3 Z coordinate
 * @param dx Vertex 4 X coordinate
 * @param dy Vertex 4 Y coordinate
 * @param dz Vertex 4 Z coordinate
 * @param x Goal point X coordinate
 * @param y Goal point Y coordinate
 * @param z Goal point Z coordinate
 * @param level Number of remaining levels
 * @return The altitude of the planet after recursive subdivision
 */
double planet(double a, double b, double c, double d, double as, double bs, double cs, double ds, double ax,
        double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double dx,
        double dy, double dz, double x, double y, double z, int level) {
    double abx;
    double aby;
    double abz;
    double acx;
    double acy;
    double acz;
    double adx;
    double ady;
    double adz;
    double bcx;
    double bcy;
    double bcz;
    double bdx;
    double bdy;
    double bdz;
    double cdx;
    double cdy;
    double cdz;
    double lab;
    double lac;
    double lad;
    double lbc;
    double lbd;
    double lcd;
    double ex;
    double ey;
    double ez;
    double e;
    double es;
    double es1;
    double es2;
    double es3;
    double eax;
    double eay;
    double eaz;
    double epx;
    double epy;
    double epz;
    double ecx;
    double ecy;
    double ecz;
    double edx;
    double edy;
    double edz;
    double x1;
    double y1;
    double z1;
    double x2;
    double y2;
    double z2;
    double l1;
    double tmp;

    if (level > 0) {
        if (level == 11) {
            this.ssa = a;
            this.ssb = b;
            this.ssc = c;
            this.ssd = d;
            this.ssas = as;
            this.ssbs = bs;
            this.sscs = cs;
            this.ssds = ds;
            this.ssax = ax;
            this.ssay = ay;
            this.ssaz = az;
            this.ssbx = bx;
            this.ssby = by;
            this.ssbz = bz;
            this.sscx = cx;
            this.sscy = cy;
            this.sscz = cz;
            this.ssdx = dx;
            this.ssdy = dy;
            this.ssdz = dz;
        }

        abx = ax - bx;
        aby = ay - by;
        abz = az - bz;
        acx = ax - cx;
        acy = ay - cy;
        acz = az - cz;
        lab = (abx * abx) + (aby * aby) + (abz * abz);
        lac = (acx * acx) + (acy * acy) + (acz * acz);

        if (lab < lac) {
            return (planet(a, c, b, d, as, cs, bs, ds, ax, ay, az, cx, cy, cz, bx, by, bz, dx, dy, dz, x, y, z,
                    level));
        } else {
            adx = ax - dx;
            ady = ay - dy;
            adz = az - dz;
            lad = (adx * adx) + (ady * ady) + (adz * adz);

            if (lab < lad) {
                return (planet(a, d, b, c, as, ds, bs, cs, ax, ay, az, dx, dy, dz, bx, by, bz, cx, cy, cz, x, y,
                        z, level));
            } else {
                bcx = bx - cx;
                bcy = by - cy;
                bcz = bz - cz;
                lbc = (bcx * bcx) + (bcy * bcy) + (bcz * bcz);

                if (lab < lbc) {
                    return (planet(b, c, a, d, bs, cs, as, ds, bx, by, bz, cx, cy, cz, ax, ay, az, dx, dy, dz,
                            x, y, z, level));
                } else {
                    bdx = bx - dx;
                    bdy = by - dy;
                    bdz = bz - dz;
                    lbd = (bdx * bdx) + (bdy * bdy) + (bdz * bdz);

                    if (lab < lbd) {
                        return (planet(b, d, a, c, bs, ds, as, cs, bx, by, bz, dx, dy, dz, ax, ay, az, cx, cy,
                                cz, x, y, z, level));
                    } else {
                        cdx = cx - dx;
                        cdy = cy - dy;
                        cdz = cz - dz;
                        lcd = (cdx * cdx) + (cdy * cdy) + (cdz * cdz);

                        if (lab < lcd) {
                            return (planet(c, d, a, b, cs, ds, as, bs, cx, cy, cz, dx, dy, dz, ax, ay, az, bx,
                                    by, bz, x, y, z, level));
                        } else {
                            es = rand2(as, bs);
                            es1 = rand2(es, es);
                            es2 = 0.5 + (0.1 * rand2(es1, es1));
                            es3 = 1.0 - es2;

                            if (ax == bx) { /* very unlikely to ever happen */
                                ex = (0.5 * ax) + (0.5 * bx);
                                ey = (0.5 * ay) + (0.5 * by);
                                ez = (0.5 * az) + (0.5 * bz);
                            } else if (ax < bx) {
                                ex = (es2 * ax) + (es3 * bx);
                                ey = (es2 * ay) + (es3 * by);
                                ez = (es2 * az) + (es3 * bz);
                            } else {
                                ex = (es3 * ax) + (es2 * bx);
                                ey = (es3 * ay) + (es2 * by);
                                ez = (es3 * az) + (es2 * bz);
                            }

                            if (lab > 1.0) {
                                lab = Math.pow(lab, 0.75);
                            }

                            e = (0.5 * (a + b)) + (es * dd1 * Math.abs(a - b))
                                    + (es1 * dd2 * Math.pow(lab, pow));
                            eax = ax - ex;
                            eay = ay - ey;
                            eaz = az - ez;
                            epx = x - ex;
                            epy = y - ey;
                            epz = z - ez;
                            ecx = cx - ex;
                            ecy = cy - ey;
                            ecz = cz - ez;
                            edx = dx - ex;
                            edy = dy - ey;
                            edz = dz - ez;

                            if (((((eax * ecy * edz) + (eay * ecz * edx) + (eaz * ecx * edy))
                                    - (eaz * ecy * edx) - (eay * ecx * edz) - (eax * ecz * edy))
                                    * (((epx * ecy * edz) + (epy * ecz * edx) + (epz * ecx * edy))
                                            - (epz * ecy * edx) - (epy * ecx * edz)
                                            - (epx * ecz * edy))) > 0.0) {
                                return (planet(c, d, a, e, cs, ds, as, es, cx, cy, cz, dx, dy, dz, ax, ay, az,
                                        ex, ey, ez, x, y, z, level - 1));
                            } else {
                                return (planet(c, d, b, e, cs, ds, bs, es, cx, cy, cz, dx, dy, dz, bx, by, bz,
                                        ex, ey, ez, x, y, z, level - 1));
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (this.doShade) {
            x1 = 0.25 * (ax + bx + cx + dx);
            x1 = (a * (x1 - ax)) + (b * (x1 - bx)) + (c * (x1 - cx)) + (d * (x1 - dx));
            y1 = 0.25 * (ay + by + cy + dy);
            y1 = (a * (y1 - ay)) + (b * (y1 - by)) + (c * (y1 - cy)) + (d * (y1 - dy));
            z1 = 0.25 * (az + bz + cz + dz);
            z1 = (a * (z1 - az)) + (b * (z1 - bz)) + (c * (z1 - cz)) + (d * (z1 - dz));
            l1 = Math.sqrt((x1 * x1) + (y1 * y1) + (z1 * z1));

            if (l1 == 0.0) {
                l1 = 1.0;
            }

            tmp = Math.sqrt(1.0 - (y * y));

            if (tmp < 0.0001) {
                tmp = 0.0001;
            }

            x2 = (x * x1) + (y * y1) + (z * z1);
            y2 = (((-x * y) / tmp * x1) + (tmp * y1)) - ((z * y) / tmp * z1);
            z2 = (-z / tmp * x1) + (x / tmp * z1);
            shade = (short) ((((-Math.sin((Math.PI * this.shadeAngle) / 180.0) * y2)
                    - (Math.cos((Math.PI * shadeAngle) / 180.0) * z2)) / l1 * 48.0) + 128.0);

            if (this.shade < 10) {
                this.shade = 10;
            }

            if (this.shade > 255) {
                this.shade = 255;
            }
        }

        return ((a + b + c + d) / 4);
    }
}

From source file:net.exclaimindustries.geohashdroid.util.KnownLocation.java

@NonNull
private Bitmap buildMarkerBitmap(@NonNull Context c) {
    // Oh, this is going to be FUN.
    int dim = c.getResources().getDimensionPixelSize(R.dimen.known_location_marker_canvas_size);
    float radius = c.getResources().getDimension(R.dimen.known_location_pin_head_radius);

    Bitmap bitmap = Bitmap.createBitmap(dim, dim, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    Paint paint = new Paint();
    paint.setAntiAlias(true);/*from ww  w. j ava 2s  .c o m*/

    KnownLocationPinData pinData = new KnownLocationPinData(c, mLocation);

    // Draw the pin line first.  That goes from the bottom-center up to
    // wherever the radius and length take us.
    float topX = Double.valueOf((dim / 2) + (pinData.getLength() * Math.cos(pinData.getAngle()))).floatValue();
    float topY = Double.valueOf(dim - (pinData.getLength() * Math.sin(pinData.getAngle()))).floatValue();
    paint.setStrokeWidth(c.getResources().getDimension(R.dimen.known_location_stroke));
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.BLACK);

    canvas.drawLine(dim / 2, dim, topX, topY, paint);

    // On the top of that line, fill in a circle.
    paint.setColor(pinData.getColor());
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(topX, topY, radius, paint);

    // And outline it.
    paint.setColor(Color.BLACK);
    paint.setStyle(Paint.Style.STROKE);
    canvas.drawCircle(topX, topY, radius, paint);

    return bitmap;
}

From source file:de.tuberlin.uebb.jdae.diff.total.TDOperations.java

public final void sin(final PDNumber[] a, final PDNumber[] target) {
    final double[] f = new double[order + 2];
    f[0] = Math.sin(a[0].values[0]);
    f[1] = Math.cos(a[0].values[0]);
    for (int n = 2; n < order + 2; n++)
        f[n] = -f[n - 2];//from   w ww.  j  a  va  2  s .c  om

    compose(f, a, target);
}

From source file:edu.csun.ecs.cs.multitouchj.application.touchpong.TouchPong.java

private void onGameStateStart() {
    wonControl.setVisible(false);/*from   w ww.  jav  a  2 s  .c o m*/
    lostControl.setVisible(false);

    Random random = new Random(new Date().getTime());
    float ballAngle = (float) random.nextInt(360);
    float ballX = (float) Math.cos(Math.toRadians(ballAngle));
    float ballY = (float) Math.sin(Math.toRadians(ballAngle));
    if (ballX == 0.0f) {
        ballX = 0.5f;
    }
    if (ballY == 0.0f) {
        ballY = 0.5f;
    }

    log.debug("angle: " + ballAngle + ", x: " + ballX + ", y: " + ballY);
    ballUnitVector.set(ballX, ballY);
    ballUnitVector = ballUnitVector.normalise(null);

    gameState = GameState.Playing;
}

From source file:Matrix4x4.java

/**
 * Apply rotation around an arbitrary axis.
 *
 * Ref: http://www.swin.edu.au/astronomy/pbourke/geometry/rotate/
 * (but be aware of errors, corrected here)
 *
 * @param angle  Angle to rotate [radians]
 * @param p0     First point defining the axis (x,y,z)
 * @param p1     Second point defining the axis (x,y,z)
 */// ww  w.j a v a2  s  .  c  o m
public void rotate(double angle, double[] p0, double[] p1) {
    // Represent axis of rotation by a unit vector [a,b,c]
    double a = p1[0] - p0[0];
    double b = p1[1] - p0[1];
    double c = p1[2] - p0[2];

    double length = Math.sqrt(a * a + b * b + c * c);

    a /= length;
    b /= length;
    c /= length;

    double d = Math.sqrt(b * b + c * c);

    // Coefficients used for step 2 matrix
    double e = d == 0.0 ? 1.0 : c / d;
    double f = d == 0.0 ? 0.0 : b / d;

    // Coefficients used for the step 3 matrix
    double k = d;
    double l = a;

    // Coefficients for the step 5 matrix (inverse of step 3)
    double m = d / (a * a + d * d);
    double n = a / (a * a + d * d);

    // Coefficients for the step 4 matrix
    double cosAngle = Math.cos(angle);
    double sinAngle = Math.sin(angle);

    //
    // Step 1
    //
    Matrix4x4 step1 = new Matrix4x4();
    step1.setElement(3, 0, -p0[0]);
    step1.setElement(3, 1, -p0[1]);
    step1.setElement(3, 2, -p0[2]);

    //
    // Step 2
    //
    Matrix4x4 step2 = new Matrix4x4();
    step2.setElement(1, 1, e);
    step2.setElement(1, 2, f);
    step2.setElement(2, 1, -f);
    step2.setElement(2, 2, e);

    //
    // Step 3
    //
    Matrix4x4 step3 = new Matrix4x4();
    step3.setElement(0, 0, k);
    step3.setElement(0, 2, l);
    step3.setElement(2, 0, -l);
    step3.setElement(2, 2, k);

    //
    // Step 4
    //
    Matrix4x4 step4 = new Matrix4x4();
    step4.setElement(0, 0, cosAngle);
    step4.setElement(0, 1, sinAngle);
    step4.setElement(1, 0, -sinAngle);
    step4.setElement(1, 1, cosAngle);

    //
    // Step 5 (inverse of step 3)
    //
    Matrix4x4 step5 = new Matrix4x4();
    step5.setElement(0, 0, m);
    step5.setElement(0, 2, -n);
    step5.setElement(2, 0, n);
    step5.setElement(2, 2, m);

    //
    // Step 6 (inverse of step 2)
    //
    Matrix4x4 step6 = new Matrix4x4();
    step6.setElement(1, 1, e);
    step6.setElement(1, 2, -f);
    step6.setElement(2, 1, f);
    step6.setElement(2, 2, e);

    //
    // Step 7 (inverse of step 1)
    //
    Matrix4x4 step7 = new Matrix4x4();
    step7.setElement(3, 0, p0[0]);
    step7.setElement(3, 1, p0[1]);
    step7.setElement(3, 2, p0[2]);

    multiply(step1);
    multiply(step2);
    multiply(step3);
    multiply(step4);
    multiply(step5);
    multiply(step6);
    multiply(step7);
}

From source file:edu.stanford.slac.archiverappliance.PB.data.BoundaryConditionsSimulationValueGenerator.java

public DBR getJCASampleValue(ArchDBRTypes type, int secondsIntoYear) {
    switch (type) {
    case DBR_SCALAR_STRING:
        DBR_TIME_String retvalss = new DBR_TIME_String(new String[] { Integer.toString(secondsIntoYear) });
        retvalss.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalss.setSeverity(1);//from   w  ww  .j  ava2s  . c  o m
        retvalss.setStatus(0);
        return retvalss;
    case DBR_SCALAR_SHORT:
        DBR_TIME_Short retvalsh;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MIN_VALUE + secondsIntoYear) });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MAX_VALUE - (secondsIntoYear - 1000)) });
        } else {
            // Check for some numbers around 0
            retvalsh = new DBR_TIME_Short(new short[] { (short) (secondsIntoYear - 2000) });
        }
        retvalsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalsh.setSeverity(1);
        retvalsh.setStatus(0);
        return retvalsh;
    case DBR_SCALAR_FLOAT:
        DBR_TIME_Float retvalfl;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvalfl = new DBR_TIME_Float(new float[] { Float.MIN_VALUE + secondsIntoYear });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvalfl = new DBR_TIME_Float(new float[] { Float.MAX_VALUE - (secondsIntoYear - 1000) });
        } else {
            // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits
            retvalfl = new DBR_TIME_Float(new float[] { (secondsIntoYear - 2000.0f) / secondsIntoYear });
        }
        retvalfl.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalfl.setSeverity(1);
        retvalfl.setStatus(0);
        return retvalfl;
    case DBR_SCALAR_ENUM:
        DBR_TIME_Enum retvalen;
        retvalen = new DBR_TIME_Enum(new short[] { (short) (secondsIntoYear) });
        retvalen.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalen.setSeverity(1);
        retvalen.setStatus(0);
        return retvalen;
    case DBR_SCALAR_BYTE:
        DBR_TIME_Byte retvalby;
        retvalby = new DBR_TIME_Byte(new byte[] { ((byte) (secondsIntoYear % 255)) });
        retvalby.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalby.setSeverity(1);
        retvalby.setStatus(0);
        return retvalby;
    case DBR_SCALAR_INT:
        DBR_TIME_Int retvalint;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvalint = new DBR_TIME_Int(new int[] { Integer.MIN_VALUE + secondsIntoYear });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvalint = new DBR_TIME_Int(new int[] { Integer.MAX_VALUE - (secondsIntoYear - 1000) });
        } else {
            // Check for some numbers around 0
            retvalint = new DBR_TIME_Int(new int[] { (secondsIntoYear - 2000) });
        }
        retvalint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalint.setSeverity(1);
        retvalint.setStatus(0);
        return retvalint;
    case DBR_SCALAR_DOUBLE:
        DBR_TIME_Double retvaldb;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvaldb = new DBR_TIME_Double(new double[] { (Double.MIN_VALUE + secondsIntoYear) });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvaldb = new DBR_TIME_Double(new double[] { (Double.MAX_VALUE - (secondsIntoYear - 1000)) });
        } else {
            // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits
            retvaldb = new DBR_TIME_Double(
                    new double[] { ((secondsIntoYear - 2000.0) / (secondsIntoYear * 1000000)) });
        }
        retvaldb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvaldb.setSeverity(1);
        retvaldb.setStatus(0);
        return retvaldb;
    case DBR_WAVEFORM_STRING:
        DBR_TIME_String retvst;
        // Varying number of copies of a typical value
        retvst = new DBR_TIME_String(
                Collections.nCopies(secondsIntoYear, Integer.toString(secondsIntoYear)).toArray(new String[0]));
        retvst.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvst.setSeverity(1);
        retvst.setStatus(0);
        return retvst;
    case DBR_WAVEFORM_SHORT:
        DBR_TIME_Short retvsh;
        retvsh = new DBR_TIME_Short(
                ArrayUtils.toPrimitive(Collections.nCopies(1, (short) secondsIntoYear).toArray(new Short[0])));
        retvsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvsh.setSeverity(1);
        retvsh.setStatus(0);
        return retvsh;
    case DBR_WAVEFORM_FLOAT:
        DBR_TIME_Float retvf;
        // Varying number of copies of a typical value
        retvf = new DBR_TIME_Float(ArrayUtils.toPrimitive(
                Collections.nCopies(secondsIntoYear, (float) Math.cos(secondsIntoYear * Math.PI / 3600))
                        .toArray(new Float[0])));
        retvf.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvf.setSeverity(1);
        retvf.setStatus(0);
        return retvf;
    case DBR_WAVEFORM_ENUM:
        DBR_TIME_Enum retven;
        retven = new DBR_TIME_Enum(ArrayUtils
                .toPrimitive(Collections.nCopies(1024, (short) secondsIntoYear).toArray(new Short[0])));
        retven.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retven.setSeverity(1);
        retven.setStatus(0);
        return retven;
    case DBR_WAVEFORM_BYTE:
        DBR_TIME_Byte retvb;
        // Large number of elements in the array
        retvb = new DBR_TIME_Byte(ArrayUtils.toPrimitive(Collections
                .nCopies(65536 * secondsIntoYear, ((byte) (secondsIntoYear % 255))).toArray(new Byte[0])));
        retvb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvb.setSeverity(1);
        retvb.setStatus(0);
        return retvb;
    case DBR_WAVEFORM_INT:
        DBR_TIME_Int retvint;
        // Varying number of copies of a typical value
        retvint = new DBR_TIME_Int(ArrayUtils.toPrimitive(Collections
                .nCopies(secondsIntoYear, secondsIntoYear * secondsIntoYear).toArray(new Integer[0])));
        retvint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvint.setSeverity(1);
        retvint.setStatus(0);
        return retvint;
    case DBR_WAVEFORM_DOUBLE:
        DBR_TIME_Double retvd;
        // Varying number of copies of a typical value
        retvd = new DBR_TIME_Double(ArrayUtils.toPrimitive(Collections
                .nCopies(secondsIntoYear, Math.sin(secondsIntoYear * Math.PI / 3600)).toArray(new Double[0])));
        retvd.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvd.setSeverity(1);
        retvd.setStatus(0);
        return retvd;
    case DBR_V4_GENERIC_BYTES:
        throw new RuntimeException("Currently don't support " + type + " when generating sample data");
    default:
        throw new RuntimeException("We seemed to have missed a DBR type when generating sample data");
    }
}

From source file:de.tuberlin.uebb.jdae.diff.total.TDOperations.java

public final void cos(final PDNumber[] a, final PDNumber[] target) {
    final double[] f = new double[order + 2];
    f[0] = Math.cos(a[0].values[0]);
    f[1] = -Math.sin(a[0].values[0]);
    for (int n = 2; n < order + 2; n++)
        f[n] = -f[n - 2];/*  w  w w. jav a 2 s .  com*/

    compose(f, a, target);
}