List of usage examples for java.lang Math cos
@HotSpotIntrinsicCandidate public static double cos(double a)
From source file:org.jfree.chart.demo.SampleXYDataset.java
/** * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... * * @param series the index (zero-based) of the series. * @param item the index (zero-based) of the required item. * * @return the y-value for the specified series and item. *//* w w w.ja v a 2s. c om*/ public double getYValue(final int series, final int item) { if (series == 0) { return new Double(Math.cos(-10.0 + this.translate + (item / 10.0))).doubleValue(); } else { return new Double(2 * (Math.sin(-10.0 + this.translate + (item / 10.0)))).doubleValue(); } }
From source file:com.comcast.cdn.traffic_control.traffic_router.core.loc.Geolocation.java
/** * Returns the great circle distance in kilometers between this {@link Geolocation} and the * specified location//from w w w. j ava 2 s .co m * * @param other * @return the great circle distance in km */ public double getDistanceFrom(final Geolocation other) { if (other != null) { final double dLat = Math.toRadians(getLatitude() - other.getLatitude()); final double dLon = Math.toRadians(getLongitude() - other.getLongitude()); final double a = (Math.sin(dLat / 2) * Math.sin(dLat / 2)) + (Math.cos(Math.toRadians(getLatitude())) * Math.cos(Math.toRadians(other.getLatitude())) * Math.sin(dLon / 2) * Math.sin(dLon / 2)); final double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return MEAN_EARTH_RADIUS * c; } else { return Double.POSITIVE_INFINITY; } }
From source file:org.jfree.graphics2d.demo.ImageTest.java
private static double[] calculateReferenceArc(double angle) { double a = (angle / 180 * Math.PI) / 2.0; double x0 = Math.cos(a); double y0 = Math.sin(a); double x1 = (4 - x0) / 3; double y1 = (1 - x0) * (3 - x0) / (3 * y0); double x2 = x1; double y2 = -y1; double x3 = x0; double y3 = -y0; return new double[] { x0, y0, x1, y1, x2, y2, x3, y3 }; }
From source file:io.github.malapert.jwcs.coordsystem.Utility.java
/** * Calculates the matrix that represents a 3d rotation around the Y axis. * * Reference: /*w w w . j ava2 s . c om*/ * ---------- * Diebel, J. 2006, Stanford University, Representing Attitude: * Euler angles, Unit Quaternions and Rotation Vectors. * http://ai.stanford.edu/~diebel/attitude.html * * Notes: * ------ * Return the rotation matrix for a rotation around the X axis. * This is a rotation in the YZ plane. Note that we construct * a new vector with: xnew = R1.x * In the literature, this rotation is usually called R1 * * @param angle Rotation angle in degrees * @return A 3x3 matrix representing the rotation about angle around Y axis. */ public final static RealMatrix rotY(double angle) { double angleRadians = Math.toRadians(angle); double[][] array = { { Math.cos(angleRadians), 0.d, -1 * Math.sin(angleRadians) }, { 0.d, 1.d, 0.d }, { Math.sin(angleRadians), 0.d, Math.cos(angleRadians) } }; return MatrixUtils.createRealMatrix(array); }
From source file:gedi.util.math.stat.distributions.PoissonBinomial.java
private void preprocess() { int n = pp.length; m = n + 1;/*from www. ja v a2 s . co m*/ int nextPowerOf2 = Integer.highestOneBit(m); if (nextPowerOf2 != m) nextPowerOf2 <<= 1; m = nextPowerOf2; n = m - 1; int ins = 0; int start = 0; for (int i = 1; i < pp.length; i++) { if (Math.abs(pp[i] - pp[start]) > 1E-10) { if (i - start > 1) { double p = pp[start]; pp[ins++] = -(i - start); pp[ins++] = p; } else { pp[ins++] = pp[i - 1]; } start = i; } } if (pp.length - start > 1) { double p = pp[start]; pp[ins++] = -(pp.length - start); pp[ins++] = p; } else { pp[ins++] = pp[pp.length - 1]; } double delta = 2 * Math.PI / m; z = new Complex[m]; z[0] = new Complex(1, 0); for (int i = 1; i <= Math.ceil(n / 2.0); i++) { double tt = i * delta; // for(int j=0;j<pp.length;j++) // { // double pj=j<opp.length?opp[j]:0; // double ax=1-pj+pj*Math.cos(tt); // double bx=pj*Math.sin(tt); // double tmp1=Math.sqrt(ax*ax+bx*bx); // double tmp2=Math.atan2(bx,ax); //atan2(x,y) // c1o+=Math.log(tmp1); // c2o+=tmp2; // } double c1 = 0.00; double c2 = 0.00; for (int j = 0; j < ins; j++) { double pj = pp[j]; double f = 1; if (pj < 0) { f = -pj; pj = pp[++j]; } double ax = 1 - pj + pj * Math.cos(tt); double bx = pj * Math.sin(tt); double tmp1 = Math.sqrt(ax * ax + bx * bx); double tmp2 = Math.atan2(bx, ax); //atan2(x,y) c1 += Math.log(tmp1) * f; c2 += tmp2 * f; } z[i] = new Complex(Math.exp(c1) * Math.cos(c2), Math.exp(c1) * Math.sin(c2)); z[z.length - i] = z[i].conjugate(); } FastFourierTransformer fft = new FastFourierTransformer(DftNormalization.STANDARD); z = fft.transform(z, TransformType.FORWARD); }
From source file:com.crs4.roodin.moduletester.CustomView.java
/** * @param canvas/*ww w. j a va 2s . c om*/ */ private void drawRadar(Canvas canvas) { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.RED); paint.setAlpha(100); float rotation = currentRotation; //gRotationZ_deg + initialMapRotation; for (int i = -35; i < 35; i = i + 2) { float arrowX1 = (float) (translateX - Math.sin(Math.toRadians(rotation + i)) * 45); float arrowY1 = (float) (translateY - Math.cos(Math.toRadians(rotation + i)) * 45); canvas.drawLine(translateX, translateY, arrowX1, arrowY1, paint); } paint.setAlpha(100); paint.setColor(Color.RED); canvas.drawCircle(translateX, translateY, 7, paint); paint.setColor(Color.YELLOW); canvas.drawCircle(translateX, translateY, 6, paint); paint.setColor(Color.RED); canvas.drawCircle(translateX, translateY, 1, paint); }
From source file:de.openali.odysseus.chart.framework.util.img.GenericChartLabelRenderer.java
private Rectangle calcSize(final GC gc, final int degree) { if (m_titleBean == null) return new Rectangle(0, 0, 0, 0); final Point textSize = calcTextSize(gc, m_titleBean.getText()); final int border = isDrawBorder() ? m_borderStyle.getStroke().getWidth() : 0; final Point overAllSize = new Point( textSize.x + border * 2 + m_titleBean.getInsets().left + m_titleBean.getInsets().right, textSize.y + border * 2 + m_titleBean.getInsets().top + m_titleBean.getInsets().bottom); final Rectangle textRect = getTextRect(m_titleBean.getTextAnchorX(), m_titleBean.getTextAnchorY(), overAllSize);// w ww. j a v a2 s . co m final double radian = Math.toRadians(degree); final double cosi = Math.cos(radian); final double sinu = Math.sin(radian); final double rotX = cosi * textRect.x + sinu * textRect.y; final double rotY = sinu * textRect.x + cosi * textRect.y; final double rotWidth = Math.abs(cosi * textRect.width) + Math.abs(sinu * textRect.height); final double rotHeight = Math.abs(sinu * textRect.width) + Math.abs(cosi * textRect.height); return new Rectangle((int) Math.round(rotX), (int) Math.round(rotY), (int) Math.round(rotWidth), (int) Math.round(rotHeight)); }
From source file:edu.ucsf.valelab.saim.calculations.SaimCalc.java
public static double fieldStrength(final double wavelength, final double angle, final double nSample, final double dOx, final double distance) { Complex rTE = fresnelTE(wavelength, angle, dOx, nSample); double phaseDiff = PhaseDiff(wavelength, angle, nSample, distance); Complex tmp = new Complex(Math.cos(phaseDiff), Math.sin(phaseDiff)); Complex fieldStrength = rTE.multiply(tmp); fieldStrength = fieldStrength.add(1.0); return fieldStrength.getReal() * fieldStrength.getReal() + fieldStrength.getImaginary() * fieldStrength.getImaginary(); }
From source file:BackEnd.B_calculation.java
private double getI_real() { double I_real = I * Math.cos(phase * (Math.PI / 180)); return I_real; }
From source file:com.ccxt.whl.utils.CommonUtils.java
/** * ??(?)?/*from www .jav a 2 s . co m*/ * * @param long1 * ? * @param lat1 * * @param long2 * ? * @param lat2 * * @return ? ?? */ public static double Distance(double long1, double lat1, double long2, double lat2) { double a, b, R; R = 6378137; // ?? lat1 = lat1 * Math.PI / 180.0; lat2 = lat2 * Math.PI / 180.0; a = lat1 - lat2; b = (long1 - long2) * Math.PI / 180.0; double d; double sa2, sb2; sa2 = Math.sin(a / 2.0); sb2 = Math.sin(b / 2.0); d = 2 * R * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2)); return d; }