List of usage examples for java.lang Math cos
@HotSpotIntrinsicCandidate public static double cos(double a)
From source file:com.wheelermarine.publicAccessSites.Updater.java
/** * Convert a UTM location to a latitude and longitude location. * * @param north the northing value.//w w w.j a va2s. c o m * @param east the easting value. * @param zone the UTM zone. * @return a Location containing the latitude and longitude. */ public static Location fromUTM(double north, double east, double zone) { double d = 0.99960000000000004; double d1 = 6378137; double d2 = 0.0066943799999999998; double d4 = (1 - Math.sqrt(1 - d2)) / (1 + Math.sqrt(1 - d2)); double d3 = d2 / (1 - d2); double d12 = (north / d) / (d1 * (1 - d2 / 4 - (3 * d2 * d2) / 64 - (5 * Math.pow(d2, 3)) / 256)); double d14 = d12 + ((3 * d4) / 2 - (27 * Math.pow(d4, 3)) / 32) * Math.sin(2 * d12) + ((21 * d4 * d4) / 16 - (55 * Math.pow(d4, 4)) / 32) * Math.sin(4 * d12) + ((151 * Math.pow(d4, 3)) / 96) * Math.sin(6 * d12); double d5 = d1 / Math.sqrt(1 - d2 * Math.sin(d14) * Math.sin(d14)); double d6 = Math.tan(d14) * Math.tan(d14); double d7 = d3 * Math.cos(d14) * Math.cos(d14); double d8 = (d1 * (1 - d2)) / Math.pow(1 - d2 * Math.sin(d14) * Math.sin(d14), 1.5); double d9 = (east - 500000) / (d5 * d); double lat = (d14 - ((d5 * Math.tan(d14)) / d8) * (((d9 * d9) / 2 - (((5 + 3 * d6 + 10 * d7) - 4 * d7 * d7 - 9 * d3) * Math.pow(d9, 4)) / 24) + (((61 + 90 * d6 + 298 * d7 + 45 * d6 * d6) - 252 * d3 - 3 * d7 * d7) * Math.pow(d9, 6)) / 720)) * 180 / Math.PI; double lon = (((zone - 1) * 6 - 180) + 3) + (((d9 - ((1 + 2 * d6 + d7) * Math.pow(d9, 3)) / 6) + (((((5 - 2 * d7) + 28 * d6) - 3 * d7 * d7) + 8 * d3 + 24 * d6 * d6) * Math.pow(d9, 5)) / 120) / Math.cos(d14)) * 180 / Math.PI; Location loc = new Location("MNDNR"); loc.setLatitude(lat); loc.setLongitude(lon); return loc; }
From source file:gdsc.smlm.function.gaussian.EllipticalGaussian2DFunction.java
public void initialise(double[] a) { this.a = a;/* w w w. ja va 2s .c o m*/ // Precalculate multiplication factors peakFactors = new double[npeaks][16]; for (int j = 0; j < npeaks; j++) { final double theta = a[j * 6 + ANGLE]; final double sx = a[j * 6 + X_SD]; final double sy = a[j * 6 + Y_SD]; final double sx2 = sx * sx; final double sy2 = sy * sy; final double sx3 = sx2 * sx; final double sy3 = sy2 * sy; final double cosSqt = Math.cos(theta) * Math.cos(theta); final double sinSqt = Math.sin(theta) * Math.sin(theta); final double sincost = Math.sin(theta) * Math.cos(theta); final double sin2t = Math.sin(2 * theta); final double cos2t = Math.cos(2 * theta); peakFactors[j][N] = ONE_OVER_TWO_PI / (sx * sy); peakFactors[j][HEIGHT] = a[j * 6 + SIGNAL] * peakFactors[j][N]; // All prefactors are negated since the Gaussian uses the exponential to the negative: // (A/2*pi*sx*sy) * exp( -( a(x-x0)^2 + 2b(x-x0)(y-y0) + c(y-y0)^2 ) ) peakFactors[j][AA] = -0.5 * (cosSqt / sx2 + sinSqt / sy2); peakFactors[j][BB] = -0.25 * (-sin2t / sx2 + sin2t / sy2); peakFactors[j][CC] = -0.5 * (sinSqt / sx2 + cosSqt / sy2); // For the angle gradient peakFactors[j][AA2] = -(-sincost / sx2 + sincost / sy2); peakFactors[j][BB2] = -0.5 * (-cos2t / sx2 + cos2t / sy2); peakFactors[j][CC2] = -(sincost / sx2 - sincost / sy2); // For the x-width gradient peakFactors[j][NX] = -1.0 / sx; peakFactors[j][AX] = cosSqt / sx3; peakFactors[j][BX] = -0.5 * sin2t / sx3; peakFactors[j][CX] = sinSqt / sx3; // For the y-width gradient peakFactors[j][NY] = -1.0 / sy; peakFactors[j][AY] = sinSqt / sy3; peakFactors[j][BY] = 0.5 * sin2t / sy3; peakFactors[j][CY] = cosSqt / sy3; } }
From source file:com.v2soft.misto.Providers.MapnikProvider.java
@Override public TileInfo getTileInfoByLocation(Location location, int zoom) { TileInfo res = new TileInfo(); res.setHeight(TILE_SIZE);// w ww . j a va2 s . co m res.setWidth(TILE_SIZE); res.setZoom(zoom); res.setLatitude((int) Math.floor((1 - Math.log(Math.tan(location.getLatitude() * Math.PI / 180) + 1 / Math.cos(location.getLatitude() * Math.PI / 180)) / Math.PI) / 2 * (1 << zoom))); double longitude = Math.floor((location.getLongitude() + 180) * worldTilesCount(zoom) / 360); res.setLongitude((int) longitude); return res; }
From source file:BackEnd.B_calculation.java
private FazorVektor calc_DB(DPoint Rp, DPoint R0, DPoint deltaL) throws DelaunayError { DPoint R_0 = new DPoint(R0.getX(), R0.getY(), R0.getZ()); R_0.setY(R0.getY() + R0_bundleY); // bundle korektura pre jeden druhy SMER // treba to priemetovat R_0.setZ(R0.getZ() + Math.cos(beta) * R0_bundleZ); // priemety R_0.setX(R0.getX() + Math.sin(beta) * R0_bundleZ); // System.out.println( "R_0= " + R_0 ); // System.out.println( "Rp= " + Rp ); ////from w w w.j ava2s .c o m // System.out.println( "deltal= " + deltaL ); double K = (this.mu0 * this.muR) / (4 * Math.PI); // kontanta DPoint R = help.substract(Rp, R_0); // rozdiel vektorov double menovatel = Math.pow(get_ABS(R), 3); FazorVektor deltaB = new FazorVektor(new Complex(0, 0), new Complex(0, 0), new Complex(0, 0)); DPoint C = vektor_sucin(deltaL, R); deltaB.setX_Real(K * ((getI_real() * C.getX()) / menovatel)); deltaB.setY_Real(K * ((getI_real() * C.getY()) / menovatel)); deltaB.setZ_Real(K * ((getI_real() * C.getZ()) / menovatel)); deltaB.setX_Imaginary(K * ((getI_image() * C.getX()) / menovatel)); deltaB.setY_Imaginary(K * ((getI_image() * C.getY()) / menovatel)); deltaB.setZ_Imaginary(K * ((getI_image() * C.getZ()) / menovatel)); return deltaB; }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
public static ComplexNumber cosh(final ComplexNumber z) { Validate.notNull(z, "z"); return new ComplexNumber(Math.cosh(z.getReal()) * Math.cos(z.getImaginary()), Math.sinh(z.getReal()) * Math.sin(z.getImaginary())); }
From source file:edu.ucsf.valelab.saim.calculations.SaimErrorFunction.java
/** * For each observedPoint.getX calculates the predicted intensity * Returns the sum of absolute errors// w w w . ja va 2 s . com * @param point {A, B, h} * @return sum of absolute errors */ @Override public double value(double[] point) { if (point.length != 3) { throw new DimensionMismatchException(point.length, 3); } double A = point[0]; double B = point[1]; double h = point[2]; double error = 0.0; for (WeightedObservedPoint observedPoint : observedPoints_) { double angle = observedPoint.getX(); Complex rTE = fresnelTE_.get(angle); double phaseDiff = SaimCalc.PhaseDiff(data_.wavelength_, angle, data_.nSample_, h); double c = rTE.getReal(); double d = rTE.getImaginary(); double val = 1 + 2 * c * Math.cos(phaseDiff) - 2 * d * Math.sin(phaseDiff) + c * c + d * d; error += Math.abs(A * val + B - observedPoint.getY()); } return error; }
From source file:CircleLayoutDemo.java
/** * Arranges the parent's Component objects in either an Ellipse or a Circle. * Ellipse is not yet implemented.//from w w w. j a va 2 s . com */ public void layoutContainer(Container parent) { int x, y, w, h, s, c; int n = parent.getComponentCount(); double parentWidth = parent.getSize().width; double parentHeight = parent.getSize().height; Insets insets = parent.getInsets(); int centerX = (int) (parentWidth - (insets.left + insets.right)) / 2; int centerY = (int) (parentHeight - (insets.top + insets.bottom)) / 2; Component comp = null; Dimension compPS = null; if (n == 1) { comp = parent.getComponent(0); x = centerX; y = centerY; compPS = comp.getPreferredSize(); w = compPS.width; h = compPS.height; comp.setBounds(x, y, w, h); } else { double r = (Math.min(parentWidth - (insets.left + insets.right), parentHeight - (insets.top + insets.bottom))) / 2; r *= 0.75; // Multiply by .75 to account for extreme right and bottom // Components for (int i = 0; i < n; i++) { comp = parent.getComponent(i); compPS = comp.getPreferredSize(); if (isCircle) { c = (int) (r * Math.cos(2 * i * Math.PI / n)); s = (int) (r * Math.sin(2 * i * Math.PI / n)); } else { c = (int) ((centerX * 0.75) * Math.cos(2 * i * Math.PI / n)); s = (int) ((centerY * 0.75) * Math.sin(2 * i * Math.PI / n)); } x = c + centerX; y = s + centerY; w = compPS.width; h = compPS.height; comp.setBounds(x, y, w, h); } } }
From source file:edu.uci.ics.jung.algorithms.layout.CircleLayout.java
public void initialize() { Dimension d = getSize();/*from ww w . j a va2 s . c o m*/ if (d != null) { if (vertex_ordered_list == null) setVertexOrder(new ArrayList<V>(getGraph().getVertices())); double height = d.getHeight(); double width = d.getWidth(); if (radius <= 0) { radius = 0.45 * (height < width ? height : width); } int i = 0; for (V v : vertex_ordered_list) { Point2D coord = transform(v); double angle = (2 * Math.PI * i) / vertex_ordered_list.size(); coord.setLocation(Math.cos(angle) * radius + width / 2, Math.sin(angle) * radius + height / 2); CircleVertexData data = getCircleData(v); data.setAngle(angle); i++; } } }
From source file:jat.core.cm.TwoBodyAPL.java
public VectorN position(double t) { double[] temp = new double[6]; // Determine step size double n = this.meanMotion(); // determine initial E and M double sqrome2 = Math.sqrt(1.0 - this.e * this.e); double cta = Math.cos(this.ta); double sta = Math.sin(this.ta); double sine0 = (sqrome2 * sta) / (1.0 + this.e * cta); double cose0 = (this.e + cta) / (1.0 + this.e * cta); double e0 = Math.atan2(sine0, cose0); double ma = e0 - this.e * Math.sin(e0); ma = ma + n * t;/* w ww .j a v a2 s . c om*/ double ea = solveKepler(ma, this.e); double sinE = Math.sin(ea); double cosE = Math.cos(ea); double den = 1.0 - this.e * cosE; double sinv = (sqrome2 * sinE) / den; double cosv = (cosE - this.e) / den; this.ta = Math.atan2(sinv, cosv); if (this.ta < 0.0) { this.ta = this.ta + 2.0 * Constants.pi; } temp = this.randv(); this.rv = new VectorN(temp); // Reset everything to before this.ta = initial_ta; VectorN out = new VectorN(3); out.x[0] = temp[0]; out.x[1] = temp[1]; out.x[2] = temp[2]; // out.print("sat pos at t"); return out; }
From source file:jtrace.object.Sphere.java
@Override public List<Vector3D[]> getWireFrameObjectFrame() { List<Vector3D[]> edgeList = new ArrayList<>(); int nLongitudeLines = 50; int nLongitudeSteps = 20; for (int i = 0; i < nLongitudeLines; i++) { double theta = 2 * Math.PI * i / nLongitudeLines; for (int j = 0; j < nLongitudeSteps; j++) { double phi = Math.PI * j / nLongitudeSteps; double phiNext = Math.PI * (j + 1) / nLongitudeSteps; Vector3D p = new Vector3D(Math.sin(phi) * Math.cos(theta), Math.sin(phi) * Math.sin(theta), Math.cos(phi)); Vector3D pNext = new Vector3D(Math.sin(phiNext) * Math.cos(theta), Math.sin(phiNext) * Math.sin(theta), Math.cos(phiNext)); Vector3D[] edge = { p, pNext }; edgeList.add(edge);//from w ww. j a v a 2 s .co m } } return edgeList; }