List of usage examples for java.lang Math PI
double PI
To view the source code for java.lang Math PI.
Click Source Link
From source file:Main.java
private static float getY(double angle, double radius) { return (float) (Math.sin(angle + Math.PI / 2) * radius); }
From source file:Main.java
public static float[] createSoundDataInFloatArray(int bufferSamples, final int sampleRate, final double frequency, double sweep) { final double rad = 2 * Math.PI * frequency / sampleRate; float[] vaf = new float[bufferSamples]; sweep = Math.PI * sweep / ((double) sampleRate * vaf.length); for (int j = 0; j < vaf.length; j++) { vaf[j] = (float) (Math.sin(j * (rad + j * sweep))); }//from w w w.j ava 2 s . c om return vaf; }
From source file:Main.java
public static short[] createSoundDataInShortArray(int bufferSamples, final int sampleRate, final double frequency, double sweep) { final double rad = 2 * Math.PI * frequency / sampleRate; short[] vai = new short[bufferSamples]; sweep = Math.PI * sweep / ((double) sampleRate * vai.length); for (int j = 0; j < vai.length; j++) { vai[j] = (short) (Math.sin(j * (rad + j * sweep)) * Short.MAX_VALUE); }//w w w. j a v a2 s. c om return vai; }
From source file:Main.java
public static byte[] createSoundDataInByteArray(int bufferSamples, final int sampleRate, final double frequency, double sweep) { final double rad = 2 * Math.PI * frequency / sampleRate; byte[] vai = new byte[bufferSamples]; sweep = Math.PI * sweep / ((double) sampleRate * vai.length); for (int j = 0; j < vai.length; j++) { int unsigned = (int) (Math.sin(j * (rad + j * sweep)) * Byte.MAX_VALUE) + Byte.MAX_VALUE & 0xFF; vai[j] = (byte) unsigned; }/*from w ww .j a v a 2s. c o m*/ return vai; }
From source file:Main.java
/** * radian to angle/* www . ja v a 2 s . co m*/ * * @param radian radian * @return angle */ public static double radian2Angle(double radian) { return radian / Math.PI * 180; }
From source file:Main.java
/** * angle to radian/*from www . jav a2s . co m*/ * * @param angle angle * @return radian */ public static double angle2Radian(double angle) { return angle / 180 * Math.PI; }
From source file:Main.java
/** * Metoda care calculeaza viteza cu care se deplaseaza intre 2 coordonate * date(Lat+long) intr-un interval de timp [time_1,time_2]. Calculam * distanta dintre cele doua coordonate folosind formula " Great-circle * distance" viteza = distanta transformata in m/diferenta dintre cei 2 * timpi primiti ca parametru/*w w w. j a v a2 s . c o m*/ */ public static double computeSpeed(double lat_1, double long_1, long time_1, double lat_2, double long_2, long time_2) { double speed; // speed->m/s double distanceKm; double distanceM; long time; double r = 6378.137; double e = (double) Math.acos( Math.sin(lat_1) * Math.sin(lat_2) + Math.cos(lat_1) * Math.cos(lat_2) * Math.cos(long_2 - long_1)); e = e / 180 * (double) Math.PI; distanceKm = e * r; distanceM = distanceKm * 1000; time = (time_2 - time_1) / 1000; speed = distanceM / time; return speed; }
From source file:Main.java
private static double reduceSinAngle(double radians) { radians %= Math.PI * 2.0; if (Math.abs(radians) > Math.PI) { radians = radians - (Math.PI * 2.0); }// ww w .j a v a 2 s.co m if (Math.abs(radians) > Math.PI / 2) { radians = Math.PI - radians; } return radians; }
From source file:Main.java
/** * @param deg/*from ww w . j a va 2 s .c om*/ * @return */ public static float calculatePiValueFromDegrees(float deg) { return roundDecimals(((-(Math.PI / 180) * deg + Math.PI / 2) / Math.PI), 3); }
From source file:Main.java
private static double calcPhase(int step, float freq, int samplingRate) { return Math.PI * step * freq / samplingRate; }