List of usage examples for java.lang Math sin
@HotSpotIntrinsicCandidate public static double sin(double a)
From source file:dnimp.Statistics.java
private double studT(double t, int n) { t = Math.abs(t);//from w w w . j a v a2s . c o m double th = Math.atan(t / Math.sqrt(n)); double sth = Math.sin(th); double cth = Math.cos(th); if (n == 1) return 1 - th / (Math.PI / 2.0); if (n % 2 == 1) { return 1 - (th + sth * cth * statCom(cth * cth, 2, n - 3, -1)) / (Math.PI / 2.0); } else { return 1 - sth * statCom(cth * cth, 1, n - 3, -1); } }
From source file:com.ables.pix.utility.PictureOps.java
public static BufferedImage tilt(BufferedImage image, double rotation) { double sin = Math.abs(Math.sin(getAngle())); double cos = Math.abs(Math.cos(getAngle())); int w = image.getWidth(), h = image.getHeight(); int neww = (int) Math.floor(w * cos + sin * h), newh = (int) Math.floor(h * cos + sin * w); GraphicsConfiguration gc = getDefaultConfiguration(); BufferedImage rotated = gc.createCompatibleImage(neww, newh); Graphics2D g = rotated.createGraphics(); g.translate((neww - w) / 2, (newh - h / 2)); g.rotate(getAngle(), w / 2, h / 2);//from w ww . j a v a2s . co m g.drawRenderedImage(image, null); g.dispose(); return rotated; }
From source file:naftoreiclag.villagefive.util.math.Vec2.java
public Vec2(Angle angle) { this.x = Math.cos(angle.getX()); this.y = Math.sin(angle.getX()); }
From source file:net.nicoulaj.benchmarks.math.DoubleSin.java
@GenerateMicroBenchmark public void math(BlackHole hole) { for (int i = 0; i < data.length - 1; i++) hole.consume(Math.sin(data[i])); }
From source file:de.tuberlin.uebb.jdae.diff.partial.PDOperations.java
public final void cos(final double[] values, final double[] target) { compose(Math.cos(values[0]), -Math.sin(values[0]), values, target); }
From source file:controller.JsonController.java
public ArrayList<JsonModel> ReadJsonCalc() throws FileNotFoundException, IOException, ParseException { FileInputStream fstream = new FileInputStream("gistfile1.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fstream)); String strLine;/*from www. j a va2s. c o m*/ ArrayList<JsonModel> result = new ArrayList<>(); JsonModel model; double L1, G1, L2, G2; //Read File Line By Line while ((strLine = br.readLine()) != null) { model = new JsonModel(); JSONParser parser = new JSONParser(); Object obj = parser.parse(strLine); JSONObject jsonObject = (JSONObject) obj; model.setLatitude((double) Double.parseDouble((String) jsonObject.get("latitude"))); model.setLongitude((double) Double.parseDouble((String) jsonObject.get("longitude"))); model.setUserIid((int) Integer.parseInt((String) jsonObject.get("user_id").toString())); model.setName(((String) jsonObject.get("name"))); L1 = Math.toRadians(model.getLatitudeDefault()); G1 = Math.toRadians(model.getLongitudeDefault()); L2 = Math.toRadians(model.getLatitude()); G2 = Math.toRadians(model.getLongitude()); // do the spherical trig calculation double angle = Math.acos(Math.sin(L1) * Math.sin(L2) + Math.cos(L1) * Math.cos(L2) * Math.cos(G1 - G2)); // convert back to degrees angle = Math.toDegrees(angle); // each degree on a great circle of Earth is 69.1105 miles double distance = (69.1105 * angle) * 1.609344; if (distance <= 100) result.add(model); } Collections.sort(result); return result; }
From source file:etomica.math.SpecialFunctions.java
/** * Returns the ln(gamma), the natural logarithm of the gamma function. * Lanczos approximation, with precision ~15 digits * coefficients from GSL (GNU Scientific Library) with g=7 */// w w w.j av a2 s .c o m public static double lnGamma(double x) { if (x < 0) { throw new IllegalArgumentException("x must not be negative"); } if (x == 0) { return 0; } if (x < 0.5) { return Math.log(Math.PI / (Math.sin(Math.PI * x))) - lnGamma(1 - x); } double tmp = x + 7 - 0.5; double ser = 0.99999999999980993; for (int i = 7; i > -1; i--) { ser += lnGammaCoeff[i] / (x + i); } double y = lnsqrt2Pi + (x - 0.5) * Math.log(tmp) - tmp + Math.log(ser); return y; }
From source file:Quaternion.java
/** * Return a quaternion representing a rotation of theta radians about the given n axis * @param theta//from ww w . j a va 2 s. c o m * @param n * @return */ public static Quaternion rotation(double theta, Vector3 n) { return new Quaternion((double) Math.cos(theta / 2.0f), n.multiply((double) Math.sin(theta / 2.0f))); }
From source file:electrical_parameters.Admittance.java
public Admittance(RealMatrix Dik, RealMatrix Dik_mirror, double[] hx2, ArrayList<elpam_input_conductor> cnd_list, double krok, // m int n_zv, // - int fv, int gw) { this.r_cnd = new double[cnd_list.size()]; if (cnd_list.get(0).isBundle()) { double rho = krok / (2 * Math.sin(Math.PI / n_zv)); for (int i = 0; i < cnd_list.size(); i++) { this.r_cnd[i] = Math.pow(n_zv * (cnd_list.get(i).getD() / 2) * Math.pow(rho, n_zv - 1), (double) 1 / n_zv); }//from w w w. j av a 2s . co m } else { for (int i = 0; i < cnd_list.size(); i++) { this.r_cnd[i] = cnd_list.get(i).getD() / 2; } } this.fv = fv; this.gw = gw; this.f = constants.getFrequency(); this.Dik = Dik; this.Dik_mirror = Dik_mirror; this.hx2 = hx2; this.P = new Array2DRowRealMatrix(fv + gw, fv + gw); this.P_red = new Array2DRowRealMatrix(fv, fv); this.C = new Array2DRowRealMatrix(fv, fv); this.B = new Array2DRowRealMatrix(fv, fv); this.Y = new ComplexMatrix(fv, fv); this.C_symm = new Array2DRowRealMatrix(fv, fv); this.B_symm = new Array2DRowRealMatrix(fv, fv); this.Y_symm = new ComplexMatrix(fv, fv); this.omega = (double) 2 * Math.PI * this.f; this.cnst = (double) 1 / (8.854187e-9 * 1 * 2 * Math.PI); }
From source file:dsp.unige.figures.ChannelHelper.java
/** * Returns the rain attenuation in dB given the state s, using procedure * from [1]. [1]. A prediction model that combines Rain Attenuation and * Other Propagation Impairments Along Earth- Satellinte Paths * /*from w w w . j a v a 2 s .co m*/ * @param s * @return rain attenuation in dB. */ public static double getRainAttenuation(Station s) { // ==================== step 1 =========================== // calculate freezing height (in km) from the absolute value of station // latitude double hFr; if (s.stationLatitude >= 0 && s.stationLatitude < 23) hFr = 5.0d; else hFr = 5.0 - 0.075 * (s.stationLatitude - 23); // ==================== step 2 =========================== // calculate slant-path length Ls below the freezing height double Ls = (hFr - s.stationAltitude) / Math.sin(s.elevationAngle * Math.PI / 180); // ==================== step 3 =========================== // calculate horizontal projection Lg of the slant path length double Lg = Ls * Math.cos(s.elevationAngle * Math.PI / 180); // ==================== step 4 =========================== // obtain rain attenuation double gamma = s.getRainK() * Math.pow(s.R001, s.getRainAlpha()); // ==================== step 5 =========================== // calculate horizontal path adjustment double rh001 = 1 / (1 + 0.78 * Math.sqrt(Lg * gamma / s.frequency) - 0.38 * (1 - Math.exp(-2 * Lg))); // ==================== step 6 =========================== // calculate the adjusted rainy path length double ZETA = Math.atan((hFr - s.stationAltitude) / (Lg * rh001)); double Lr; if (ZETA > s.elevationAngle) { Lr = (Lg * rh001) / (Math.cos(s.elevationAngle * Math.PI / 180)); } else { Lr = (hFr - s.stationAltitude) / (Math.sin(s.elevationAngle * Math.PI / 180)); } // ==================== step 7 =========================== // calculate vertical path adjustment double CHI; if (Math.abs(s.elevationAngle) < 36) { CHI = 36 - s.elevationAngle; } else { CHI = 0; } double rv001 = 1 / (1 + Math.sqrt(Math.sin(s.elevationAngle * Math.PI / 180)) * (31 * (1 - Math.exp(-s.elevationAngle / (1 + CHI))) * (Math.sqrt(Lr * gamma) / Math.pow(s.frequency, 2)) - 0.45)); // ==================== step 8 =========================== // effective path length through rain double Le = Lr * rv001; // ==================== step 9 =========================== // get the attenuation exceded in 0.01% of average year time double A001 = gamma * Le; return A001; }