List of usage examples for java.lang Math cos
@HotSpotIntrinsicCandidate public static double cos(double a)
From source file:es.emergya.geo.util.Lambert.java
/** * Translate latitude/longitude in WGS84, (ellipsoid GRS80) to Lambert * geographic, (ellipsoid Clark)/*from www.j a va 2s . c o m*/ */ private LatLon GRS802Clark(LatLon wgs) { double lat = Math.toRadians(wgs.lat()); // degree to radian double lon = Math.toRadians(wgs.lon()); // WGS84 geographic => WGS84 cartesian double N = Ellipsoid.GRS80.a / (Math.sqrt(1.0 - Ellipsoid.GRS80.e2 * Math.sin(lat) * Math.sin(lat))); double X = (N/* +height */) * Math.cos(lat) * Math.cos(lon); double Y = (N/* +height */) * Math.cos(lat) * Math.sin(lon); double Z = (N * (1.0 - Ellipsoid.GRS80.e2)/* + height */) * Math.sin(lat); // WGS84 => Lambert ellipsoide similarity X += 168.0; Y += 60.0; Z += -320.0; // Lambert cartesian => Lambert geographic return Geographic(X, Y, Z, Ellipsoid.clarke); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment22.java
public double getDistanceBetweenTwoCoordiantes(double lat1, double lat2, double lon1, double lon2) { try {/* w w w .j a v a 2s . c om*/ double R = 6371.0; // km double dLat = toRad(lat2 - lat1); double dLon = toRad(lon2 - lon1); double a = Math.sin(dLat / 2.0) * Math.sin(dLat / 2.0) + Math.sin(dLon / 2.0) * Math.sin(dLon / 2.0) * Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)); double c = 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a)); double d = R * c; // return unit meter return d * 1000; } catch (Exception e) { return 0; } }
From source file:com.kircherelectronics.accelerationexplorer.filter.ImuLaKfQuaternion.java
/** * Create an angle-axis vector, in this case a unit quaternion, from the * provided Euler angle's (presumably from SensorManager.getOrientation()). * //from w ww .j a va 2 s. c o m * Equation from * http://www.euclideanspace.com/maths/geometry/rotations/conversions * /eulerToQuaternion/ * * @param orientation */ private void getRotationVectorFromAccelMag(float[] orientation) { // Assuming the angles are in radians. // getOrientation() values: // values[0]: azimuth, rotation around the Z axis. // values[1]: pitch, rotation around the X axis. // values[2]: roll, rotation around the Y axis. // Heading, Azimuth, Yaw double c1 = Math.cos(orientation[0] / 2); double s1 = Math.sin(orientation[0] / 2); // Pitch, Attitude // The equation assumes the pitch is pointed in the opposite direction // of the orientation vector provided by Android, so we invert it. double c2 = Math.cos(-orientation[1] / 2); double s2 = Math.sin(-orientation[1] / 2); // Roll, Bank double c3 = Math.cos(orientation[2] / 2); double s3 = Math.sin(orientation[2] / 2); double c1c2 = c1 * c2; double s1s2 = s1 * s2; double w = c1c2 * c3 - s1s2 * s3; double x = c1c2 * s3 + s1s2 * c3; double y = s1 * c2 * c3 + c1 * s2 * s3; double z = c1 * s2 * c3 - s1 * c2 * s3; // The quaternion in the equation does not share the same coordinate // system as the Android gyroscope quaternion we are using. We reorder // it here. // Android X (pitch) = Equation Z (pitch) // Android Y (roll) = Equation X (roll) // Android Z (azimuth) = Equation Y (azimuth) vectorAccelMag[0] = z; vectorAccelMag[1] = x; vectorAccelMag[2] = y; vectorAccelMag[3] = w; if (!hasOrientation) { quatAccelMag = new Quaternion(w, z, x, y); } }
From source file:com.bitnine.tadpole.graph.core.editor.extension.browserHandler.CypherFunctionService.java
/** * Sigma.js ?? ? ./*from w ww.j a v a2 s . c o m*/ * * @param nodeJsonString * @return */ protected String loadDataWithSigma(final String nodeJsonString) { String result = ""; JsonObject jsonNode = JsonObject.readFrom(nodeJsonString); ResultSet rs = null; java.sql.Connection javaConn = null; Statement statement = null; try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); String reqQuery = "match (n)-[r]->(p) where id(n) = '" + jsonNode.get("id").asString() + "' return n, r, p UNION match (n)-[r]->(p) where id(p) = '" + jsonNode.get("id").asString() + "' return n, r, p"; if (logger.isDebugEnabled()) logger.debug("Execute Math CQL : " + reqQuery); javaConn = client.getDataSource().getConnection(); statement = javaConn.createStatement(); rs = statement.executeQuery(reqQuery); ResultSetMetaData rsmt = rs.getMetaData(); SigmaGraph graph = new SigmaGraph(); Node node = null; GEdge edge = null; long row = 0; double parentAngle = 0; double angleDeg = 0; double nx = 0; double ny = 0; while (rs.next()) { row++; for (int columnIndex = 1; columnIndex <= rsmt.getColumnCount(); columnIndex++) { Object obj = rs.getObject(columnIndex); if (obj instanceof Vertex) { node = new Node(); Vertex vertex = (Vertex) obj; node.setLabel(vertex.getLabel()); angleDeg = (((360 / (rsmt.getColumnCount() * 10)) * (columnIndex * row))); nx = jsonNode.get("x").asDouble() + (100 * Math.cos((angleDeg * (Math.PI / 180)) - parentAngle)); ny = jsonNode.get("y").asDouble() + (100 * Math.sin((angleDeg * (Math.PI / 180)) - parentAngle)); node.setX(nx); node.setY(ny); node.setColor(AgensUtils.getRandomRGB()); node.setSize(500); graph.addNode(node); } else if (obj instanceof Edge) { edge = new GEdge(); Edge relation = (Edge) obj; edge.setId(relation.getEdgeId().getOid() + "." + relation.getEdgeId().getId()); edge.setLabel(relation.getLabel()); edge.setSource( relation.getStartVertexId().getOid() + "." + relation.getStartVertexId().getId()); edge.setTarget( relation.getEndVertexid().getOid() + "." + relation.getEndVertexid().getId()); edge.setType("arrow");//'line', 'curve', 'arrow', 'curvedArrow' edge.setColor(AgensUtils.getRandomRGB("100")); edge.setSize(0.5); if (logger.isDebugEnabled()) logger.debug("Relation is " + relation.toString() + ", edge is " + edge.toString()); graph.addEdge(edge); } else { if (logger.isDebugEnabled()) logger.debug("Unknow Class " + obj.getClass().toString()); } } } Gson gson = new Gson(); result = gson.toJson(graph); if (logger.isDebugEnabled()) logger.debug("##### Graph ####====>" + result); } catch (Exception e) { logger.error(e); } finally { try { if (statement != null) statement.close(); } catch (Exception e) { } try { if (rs != null) rs.close(); } catch (Exception e) { } try { if (javaConn != null) javaConn.close(); } catch (Exception e) { } } return result; }
From source file:ExDepthCue.java
public Shape3D buildSurface(double freqAlpha, double freqTheta, double radius, float red, float green, float blue) { int nAngles = 64; double amp = radius / 4.0; int nAlpha = nAngles / 2; double theta, alpha; double x, y, z, rprime, r; double deltaTheta, deltaAlpha; int i, j;//from w w w. j av a2 s. c o m int i1, i2, i3, i4; deltaTheta = 360.0 / (nAngles - 1.0); deltaAlpha = 180.0 / (nAlpha - 1.0); // Build an appearance Appearance app = new Appearance(); LineAttributes latt = new LineAttributes(); latt.setLineWidth(1.0f); app.setLineAttributes(latt); ColoringAttributes catt = new ColoringAttributes(); catt.setColor(red, green, blue); app.setColoringAttributes(catt); PolygonAttributes patt = new PolygonAttributes(); patt.setCullFace(PolygonAttributes.CULL_NONE); patt.setPolygonMode(PolygonAttributes.POLYGON_LINE); app.setPolygonAttributes(patt); // Compute coordinates double[] coordinates = new double[nAlpha * nAngles * 3]; alpha = 90.0; int n = 0; for (i = 0; i < nAlpha; i++) { theta = 0.0; for (j = 0; j < nAngles; j++) { r = radius + amp * Math.sin((freqAlpha * ((double) i / (double) (nAlpha - 1)) + freqTheta * ((double) j / (double) (nAngles - 1))) * 2.0 * Math.PI); y = r * Math.sin(alpha / 180.0 * Math.PI); rprime = y / Math.tan(alpha / 180.0 * Math.PI); x = rprime * Math.cos(theta / 180.0 * Math.PI); z = rprime * Math.sin(theta / 180.0 * Math.PI); coordinates[n + 0] = x; coordinates[n + 1] = y; coordinates[n + 2] = z; n += 3; theta += deltaTheta; } alpha -= deltaAlpha; } // Compute coordinate indexes int[] indexes = new int[(nAlpha - 1) * nAngles * 4]; n = 0; for (i = 0; i < nAlpha - 1; i++) { for (j = 0; j < nAngles; j++) { i1 = i * nAngles + j; if (j == nAngles - 1) { i2 = i1 - j; i3 = (i + 1) * nAngles; } else { i2 = i1 + 1; i3 = (i + 1) * nAngles + j + 1; } i4 = (i + 1) * nAngles + j; indexes[n + 0] = i1; indexes[n + 1] = i2; indexes[n + 2] = i3; indexes[n + 3] = i4; n += 4; } } // Build the shape IndexedQuadArray lines = new IndexedQuadArray(coordinates.length / 3, // Number // of // coordinates GeometryArray.COORDINATES, // coordinates only indexes.length); // Number of indexes lines.setCoordinates(0, coordinates); lines.setCoordinateIndices(0, indexes); Shape3D shape = new Shape3D(lines, app); return shape; }
From source file:com.nextgis.rehacompdemo.RoutingActivity.java
private double getOffsetLongitude(Location location, double offset) { return location.getLongitude() + (180 / Math.PI) * (offset / 6378137.0) / Math.cos(Math.PI / 180 * location.getLatitude()); }
From source file:com.example.gps_project.Places.java
public static double GetDistance(double lat1, double lng1, double lat2, double lng2) { double radLat1 = rad(lat1); double radLat2 = rad(lat2); double a = radLat1 - radLat2; double b = rad(lng1) - rad(lng2); double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); s = s * EARTH_RADIUS;/*from w w w.j a v a 2s .c o m*/ s = Math.round(s * 10000) / 10000; return s; }
From source file:uk.ac.cam.cl.dtg.util.locations.PostCodeIOLocationResolver.java
/** * @param lat1/* ww w. j av a2s. c o m*/ * - latitude 1 * @param lon1 * - longitude 1 * @param lat2 * - latitude 2 * @param lon2 * - longitude 2 * @return - distance in miles */ private double getLatLonDistanceInMiles(final double lat1, final double lon1, final double lat2, final double lon2) { // borrowed from http://www.movable-type.co.uk/scripts/latlong.html int R = 6371000; double phi1 = Math.toRadians(lat1); double phi2 = Math.toRadians(lat2); double deltaPhi = Math.toRadians(lat2 - lat1); double deltaLambda = Math.toRadians(lon2 - lon1); double a = Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) + Math.cos(phi1) * Math.cos(phi2) * Math.sin(deltaLambda / 2) * Math.sin(deltaLambda / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double d = R * c; // convert from metres to miles d = (d / 1000) * 0.621371; return d; }
From source file:edu.cuny.qc.speech.AuToBI.PitchExtractor.java
/** * A Java implementation of Paul Boersma's pitch extraction algorithm. Implemented in Praat, and called by To * Pitch(ac).../*from w w w . j a v a2s.c o m*/ * * @param time_step The time step to extract pitch values at * @param min_pitch The minimum valid pitch * @param periods_per_window Number of periods per window * @param max_candidates The number of pitch candidates to consider * @param silence_thresh The silence threshold * @param voicing_thresh The voicing threshold * @param octave_cost The octave cost * @param octave_jump_cost The octave jump cost * @param voiced_unvoiced_cost The voiced to unvoiced transition cost * @param max_pitch THe maximum valid pitch * @return A list of TimeValuePairs containing pitch information * @throws AuToBIException if there's a problem */ public Contour soundToPitchAc(double time_step, double min_pitch, double periods_per_window, int max_candidates, double silence_thresh, double voicing_thresh, double octave_cost, double octave_jump_cost, double voiced_unvoiced_cost, double max_pitch) throws AuToBIException { double duration; double t0; int i, j; double dt_window; /* Window length in seconds. */ int nsamp_window, halfnsamp_window; /* Number of samples per window. */ int nFrames; int maximumLag; int iframe, nsampFFT; double frame[][]; double ac[]; double window[]; double windowR[]; double globalPeak; double interpolation_depth; int nsamp_period, halfnsamp_period; /* Number of samples in longest period. */ int brent_ixmax, brent_depth; if (max_candidates < max_pitch / min_pitch) max_candidates = (int) Math.floor(max_pitch / min_pitch); if (time_step <= 0.0) { time_step = periods_per_window / min_pitch / 4.0; /* e.g. 3 periods, 75 Hz: 10 milliseconds. */ } // Exclusively implementing the AC_HANNING case brent_depth = NUM_PEAK_INTERPOLATE_SINC70; interpolation_depth = 0.5; duration = wav.getDuration(); if (min_pitch < periods_per_window / duration) { throw new AuToBIException("For this Sound, the parameter 'minimum pitch' may not be less than " + (periods_per_window / duration) + " Hz."); } /* * Determine the number of samples in the longest period. * We need this to compute the local mean of the sound (looking one period in both directions), * and to compute the local peak of the sound (looking half a period in both directions). */ nsamp_period = (int) Math.floor(1 / wav.getFrameSize() / min_pitch); halfnsamp_period = nsamp_period / 2 + 1; if (max_pitch > 0.5 / wav.getFrameSize()) max_pitch = 0.5 / wav.getFrameSize(); /* * Determine window length in seconds and in samples. */ dt_window = periods_per_window / min_pitch; nsamp_window = (int) Math.floor(dt_window / wav.getFrameSize()); halfnsamp_window = nsamp_window / 2 - 1; if (halfnsamp_window < 2) { throw new AuToBIException("Analysis window too short."); } nsamp_window = halfnsamp_window * 2; /* * Determine the maximum lag. */ maximumLag = (int) (Math.floor(nsamp_window / periods_per_window) + 2); if (maximumLag > nsamp_window) maximumLag = nsamp_window; if (wav.getDuration() < dt_window) { throw new AuToBIException("Wav data is shorter than pitch analysis window."); } Pair<Integer, Double> pair = getNFramesAndStartTime(time_step, dt_window); nFrames = pair.first; t0 = pair.second; /* * Create the resulting pitch contour. */ Contour pitch = new Contour(t0, time_step, nFrames); /* * Compute the global absolute peak for determination of silence threshold. */ globalPeak = 0.0; for (int channel = 0; channel < wav.numberOfChannels; ++channel) { double mean = 0.0; for (i = 0; i < wav.getNumSamples(); ++i) { mean += wav.getSample(channel, i); } mean /= wav.getNumSamples(); for (i = 0; i < wav.getNumSamples(); ++i) { double value = Math.abs(wav.getSample(channel, i) - mean); if (value > globalPeak) globalPeak = value; } } if (globalPeak == 0.0) { return pitch; } /* * Compute the number of samples needed for doing FFT. * To avoid edge effects, we have to append zeroes to the window. * The maximum lag considered for maxima is maximumLag. * The maximum lag used in interpolation is nsamp_window * interpolation_depth. */ nsampFFT = 1; while (nsampFFT < nsamp_window * (1 + interpolation_depth)) nsampFFT *= 2; /* * Create buffers for autocorrelation analysis. */ frame = new double[wav.numberOfChannels][nsampFFT]; windowR = new double[nsampFFT]; window = new double[nsamp_window]; ac = new double[nsampFFT]; /* Hanning window. */ for (i = 0; i < nsamp_window; i++) { window[i] = 0.5 - 0.5 * Math.cos((i + 1) * 2 * Math.PI / (nsamp_window + 1)); } /* * Compute the normalized autocorrelation of the window. */ for (i = 0; i < nsamp_window; i++) { windowR[i] = window[i]; } for (i = nsamp_window; i < nsampFFT; ++i) { windowR[i] = 0.0; } // Forward FFT RealDoubleFFT_Radix2 window_fft = new RealDoubleFFT_Radix2(nsampFFT); window_fft.transform(windowR); windowR[0] *= windowR[0]; for (i = 1; i < nsampFFT; ++i) { // calculate the power spectrum // absolute value of the fft if (i <= nsampFFT / 2) { // The real part windowR[i] = windowR[i] * windowR[i] + windowR[nsampFFT - i] * windowR[nsampFFT - i]; } else { // The imaginary part windowR[i] = 0; } } window_fft.inverse(windowR); for (i = 1; i < nsamp_window; i++) { windowR[i] = windowR[i] / windowR[0]; /* Normalize. */ } windowR[0] = 1.0; brent_ixmax = (int) (nsamp_window * interpolation_depth); int[] imax = new int[max_candidates]; // Start to calculate pitch ArrayList<PitchFrame> pitchFrames = new ArrayList<PitchFrame>(); for (iframe = 0; iframe < nFrames; iframe++) { // It's unclear to me what Sound_to_Pitch.c:224 means // Pitch_Frame pitchFrame = & thy frame [iframe]; // it seems as though there are two 'frame' variables. // 'thy frame' is an array of Pitch_Frames with nFrames elements // 'frame' is a channels by nsampFFT matrix PitchFrame pitchFrame = new PitchFrame(); double t = indexToX(t0, time_step, iframe); double localPeak; int leftSample = xToLowIndex(0.0, wav.getFrameSize(), t); int rightSample = leftSample + 1; int startSample, endSample; double localMean[] = new double[wav.numberOfChannels]; for (int channel = 0; channel < wav.numberOfChannels; ++channel) { /* * Compute the local mean; look one longest period to both sides. */ startSample = Math.max(0, rightSample - nsamp_period); endSample = Math.min(wav.getNumSamples(), leftSample + nsamp_period); localMean[channel] = 0.0; for (i = startSample; i <= endSample; i++) { localMean[channel] += wav.getSample(channel, i); } localMean[channel] /= 2 * nsamp_period; /* * Copy a window to a frame and subtract the local mean. * We are going to kill the DC component before windowing. */ startSample = Math.max(0, rightSample - halfnsamp_window); //endSample = Math.min(wav.getNumSamples()-1, leftSample + halfnsamp_window); for (j = 0, i = startSample; j < nsamp_window; j++) frame[channel][j] = (wav.getSample(channel, i++) - localMean[channel]) * window[j]; for (j = nsamp_window + 1; j < nsampFFT; j++) frame[channel][j] = 0.0; } /* * Compute the local peak; look half a longest period to both sides. */ localPeak = 0.0; if ((startSample = halfnsamp_window + 1 - halfnsamp_period) < 1) { startSample = 0; } if ((endSample = halfnsamp_window + halfnsamp_period) > nsamp_window) endSample = nsamp_window; for (int channel = 0; channel < wav.numberOfChannels; ++channel) { for (j = startSample; j <= endSample; j++) { double value = Math.abs(frame[channel][j]); if (value > localPeak) localPeak = value; } } pitchFrame.setIntensity(localPeak > globalPeak ? 1.0 : localPeak / globalPeak); /* * The FFT of the autocorrelation is the power spectrum. */ for (i = 0; i < nsampFFT; i++) { ac[i] = 0.0; } for (int channel = 0; channel < wav.numberOfChannels; ++channel) { // FFT forward RealDoubleFFT_Radix2 frame_fft = new RealDoubleFFT_Radix2(nsampFFT); frame_fft.transform(frame[channel]); ac[0] += frame[channel][0] * frame[channel][0]; /* DC component. */ for (i = 1; i < nsampFFT - 1; ++i) { /* Power spectrum. */ if (i <= nsampFFT / 2) { // The real part ac[i] += frame[channel][i] * frame[channel][i] + frame[channel][nsampFFT - i] * frame[channel][nsampFFT - i]; } } } // FFT backward RealDoubleFFT_Radix2 ac_fft = new RealDoubleFFT_Radix2(nsampFFT); ac_fft.inverse(ac); /* * Normalize the autocorrelation to the value with zero lag, * and divide it by the normalized autocorrelation of the window. */ NegativeSymmetricList r = new NegativeSymmetricList(); r.add(1.0); for (i = 0; i < brent_ixmax; i++) { r.add(ac[i + 1] / (ac[0] * windowR[i + 1])); } /* * Register the first candidate, which is always present: voicelessness. */ pitchFrame.addCandidate(); pitchFrame.getCandidate(0).frequency = 0.0; // Voiceless: always present. pitchFrame.getCandidate(0).strength = 0.0; /* * Shortcut: absolute silence is always voiceless. * Go to next frame. */ if (localPeak == 0) { pitchFrames.add(pitchFrame); continue; } /* * Find the strongest maxima of the correlation of this frame, * and register them as candidates. */ imax[1] = 0; for (i = 1; i < maximumLag && i < brent_ixmax; i++) { if (r.get(i) > 0.5 * voicing_thresh && /* Not too unvoiced? */ r.get(i) > r.get(i - 1) && r.get(i) >= r.get(i + 1)) /* Maximum? */ { int place = 0; /* * Use parabolic interpolation for first estimate of frequency, * and sin(x)/x interpolation to compute the strengths of this frequency. */ double dr = 0.5 * (r.get(i + 1) - r.get(i - 1)), d2r = 2 * r.get(i) - r.get(i - 1) - r.get(i + 1); double frequencyOfMaximum = 1.0 / wav.getFrameSize() / (i + dr / d2r); int offset = -brent_ixmax - 1; double strengthOfMaximum = /* method & 1 ? */ interpolateSinc(r, offset, brent_ixmax - offset, 1.0 / wav.getFrameSize() / frequencyOfMaximum - offset, 30) /* : r [i] + 0.5 * dr * dr / d2r */; /* High values due to short windows are to be reflected around 1. */ if (strengthOfMaximum > 1.0) strengthOfMaximum = 1.0 / strengthOfMaximum; /* * Find a place for this maximum. */ if (pitchFrame.getNumCandidates() < max_candidates) { /* Is there still a free place? */ place = pitchFrame.getNumCandidates(); pitchFrame.addCandidate(); } else { /* Try the place of the weakest candidate so far. */ double weakest = 1; int iweak; for (iweak = 1; iweak < max_candidates; ++iweak) { /* High frequencies are to be favoured */ /* if we want to analyze a perfectly periodic signal correctly. */ double localStrength = pitchFrame.getCandidate(iweak).strength - octave_cost * Math.log(min_pitch / pitchFrame.getCandidate(iweak).frequency) / Math.log(2); if (localStrength < weakest) { weakest = localStrength; place = iweak; } } /* If this maximum is weaker than the weakest candidate so far, give it no place. */ if (strengthOfMaximum - octave_cost * Math.log(min_pitch / frequencyOfMaximum) / Math.log(2) <= weakest) { place = -1; } } /* Have we found a place for this candidate? */ if (place >= 0) { pitchFrame.getCandidate(place).frequency = frequencyOfMaximum; pitchFrame.getCandidate(place).strength = strengthOfMaximum; imax[place] = i; } } } /* * Second pass: for extra precision, maximize sin(x)/x interpolation ('sinc'). */ for (i = 1; i < pitchFrame.getNumCandidates(); i++) { if (pitchFrame.getCandidate(i).frequency > 0.0) { double xmid; double ymid; int offset = -brent_ixmax - 1; Pair<Double, Double> max_results = improveMaximum(r, offset, brent_ixmax - offset, imax[i] - offset, pitchFrame.getCandidate(i).frequency > 0.3 / wav.getFrameSize() ? NUM_PEAK_INTERPOLATE_SINC700 : brent_depth); ymid = max_results.first; xmid = max_results.second; xmid += offset; pitchFrame.getCandidate(i).frequency = 1.0 / wav.getFrameSize() / xmid; if (ymid > 1.0) ymid = 1.0 / ymid; pitchFrame.getCandidate(i).strength = ymid; } } pitchFrames.add(pitchFrame); } /* Next frame. */ // Use path finding with constraints to find the lowest cost path through pitch candidates pitch = pathFinder(pitchFrames, silence_thresh, voicing_thresh, octave_cost, octave_jump_cost, voiced_unvoiced_cost, max_pitch, max_candidates, time_step, t0); return pitch; }
From source file:com.samknows.measurement.activity.SamKnowsMapActivity.java
private LatLng getPoint(LatLng center, int radius, double angle) { // Get the coordinates of a circle point at the given angle double east = radius * Math.cos(angle); double north = radius * Math.sin(angle); double cLat = center.latitude; double cLng = center.longitude; double latRadius = 6371000 * Math.cos(cLat / 180 * Math.PI); double newLat = cLat + (north / 6371000 / Math.PI * 180); double newLng = cLng + (east / latRadius / Math.PI * 180); return new LatLng(newLat, newLng); }