Java examples for java.lang:Math Trigonometric Function
Returns haversine(angle-in-radians).
//package com.java2s; import static java.lang.Math.*; public class Main { /**/* w w w .j av a 2 s . c o m*/ * Returns haversine(angle-in-radians). * hav(x) == (1 - cos(x)) / 2 == sin(x / 2)^2. */ static double hav(double x) { double sinHalf = sin(x * 0.5); return sinHalf * sinHalf; } }