List of usage examples for java.lang Math asin
public static double asin(double a)
From source file:org.apache.sysml.runtime.functionobjects.Builtin.java
public double execute(double in) throws DMLRuntimeException { switch (bFunc) { case SIN:/* w w w . j a v a 2 s . co m*/ return FASTMATH ? FastMath.sin(in) : Math.sin(in); case COS: return FASTMATH ? FastMath.cos(in) : Math.cos(in); case TAN: return FASTMATH ? FastMath.tan(in) : Math.tan(in); case ASIN: return FASTMATH ? FastMath.asin(in) : Math.asin(in); case ACOS: return FASTMATH ? FastMath.acos(in) : Math.acos(in); case ATAN: return Math.atan(in); //faster in Math case CEIL: return FASTMATH ? FastMath.ceil(in) : Math.ceil(in); case FLOOR: return FASTMATH ? FastMath.floor(in) : Math.floor(in); case LOG: return FASTMATH ? FastMath.log(in) : Math.log(in); case LOG_NZ: return (in == 0) ? 0 : FASTMATH ? FastMath.log(in) : Math.log(in); case ABS: return Math.abs(in); //no need for FastMath case SIGN: return FASTMATH ? FastMath.signum(in) : Math.signum(in); case SQRT: return Math.sqrt(in); //faster in Math case EXP: return FASTMATH ? FastMath.exp(in) : Math.exp(in); case ROUND: return Math.round(in); //no need for FastMath case PLOGP: if (in == 0.0) return 0.0; else if (in < 0) return Double.NaN; else return (in * (FASTMATH ? FastMath.log(in) : Math.log(in))); case SPROP: //sample proportion: P*(1-P) return in * (1 - in); case SIGMOID: //sigmoid: 1/(1+exp(-x)) return FASTMATH ? 1 / (1 + FastMath.exp(-in)) : 1 / (1 + Math.exp(-in)); case SELP: //select positive: x*(x>0) return (in > 0) ? in : 0; default: throw new DMLRuntimeException("Builtin.execute(): Unknown operation: " + bFunc); } }
From source file:se.llbit.chunky.world.entity.PlayerEntity.java
public void lookAt(Vector3d camera) { Vector3d dir = new Vector3d(camera); Vector3d face = new Vector3d(position); face.add(0, 28 / 16., 0);// w ww . j a va 2 s .co m dir.sub(face); dir.normalize(); yaw = FastMath.atan2(dir.x, dir.z) + Math.PI - headYaw; pitch = Math.asin(dir.y); }
From source file:se.llbit.chunky.renderer.scene.Sky.java
/** * Bilinear interpolated panoramic skymap color * @param ray//from www. ja v a2 s .c o m */ public void getSkyColorInterpolated(Ray ray) { switch (mode) { case SKYMAP_PANORAMIC: { if (mirrored) { double theta = FastMath.atan2(ray.d.z, ray.d.x); theta += rotation; theta /= Constants.TAU; theta = (theta % 1 + 1) % 1; double phi = Math.abs(Math.asin(ray.d.y)) / Constants.HALF_PI; skymap.getColorInterpolated(theta, phi, ray.color); } else { double theta = FastMath.atan2(ray.d.z, ray.d.x); theta += rotation; theta /= Constants.TAU; if (theta > 1 || theta < 0) { theta = (theta % 1 + 1) % 1; } double phi = (Math.asin(ray.d.y) + Constants.HALF_PI) / Math.PI; skymap.getColorInterpolated(theta, phi, ray.color); } break; } case SKYMAP_SPHERICAL: { double cos = FastMath.cos(-rotation); double sin = FastMath.sin(-rotation); double x = cos * ray.d.x + sin * ray.d.z; double y = ray.d.y; double z = -sin * ray.d.x + cos * ray.d.z; double len = Math.sqrt(x * x + y * y); double theta = (len < Ray.EPSILON) ? 0 : Math.acos(-z) / (Constants.TAU * len); double u = theta * x + .5; double v = .5 + theta * y; skymap.getColorInterpolated(u, v, ray.color); break; } case SKYBOX: { double cos = FastMath.cos(-rotation); double sin = FastMath.sin(-rotation); double x = cos * ray.d.x + sin * ray.d.z; double y = ray.d.y; double z = -sin * ray.d.x + cos * ray.d.z; double xabs = QuickMath.abs(x); double yabs = QuickMath.abs(y); double zabs = QuickMath.abs(z); if (y > xabs && y > zabs) { double alpha = 1 / yabs; skybox[SKYBOX_UP].getColorInterpolated((1 + x * alpha) / 2.0, (1 + z * alpha) / 2.0, ray.color); } else if (-z > xabs && -z > yabs) { double alpha = 1 / zabs; skybox[SKYBOX_FRONT].getColorInterpolated((1 + x * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); } else if (z > xabs && z > yabs) { double alpha = 1 / zabs; skybox[SKYBOX_BACK].getColorInterpolated((1 - x * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); } else if (-x > zabs && -x > yabs) { double alpha = 1 / xabs; skybox[SKYBOX_LEFT].getColorInterpolated((1 - z * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); } else if (x > zabs && x > yabs) { double alpha = 1 / xabs; skybox[SKYBOX_RIGHT].getColorInterpolated((1 + z * alpha) / 2.0, (1 + y * alpha) / 2.0, ray.color); } else if (-y > xabs && -y > zabs) { double alpha = 1 / yabs; skybox[SKYBOX_DOWN].getColorInterpolated((1 + x * alpha) / 2.0, (1 - z * alpha) / 2.0, ray.color); } break; } default: getSkyDiffuseColorInner(ray); } if (scene.sunEnabled) { addSunColor(ray); } //ray.color.scale(skyLightModifier); ray.color.w = 1; }
From source file:com.irsa.OnTheGoActivity.java
private double gps2m(double lat_a, double lng_a, double lat_b, double lng_b) { double radLat1 = (lat_a * Math.PI / 180.0); double radLat2 = (lat_b * Math.PI / 180.0); double a = radLat1 - radLat2; double b = (lng_a - lng_b) * Math.PI / 180.0; 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 a2s.c o m*/ s = Math.round(s * 10000) / 10000; return s; }
From source file:com.ibm.bi.dml.runtime.functionobjects.Builtin.java
public double execute(double in) throws DMLRuntimeException { switch (bFunc) { case SIN://from w ww . jav a 2 s . c o m return FASTMATH ? FastMath.sin(in) : Math.sin(in); case COS: return FASTMATH ? FastMath.cos(in) : Math.cos(in); case TAN: return FASTMATH ? FastMath.tan(in) : Math.tan(in); case ASIN: return FASTMATH ? FastMath.asin(in) : Math.asin(in); case ACOS: return FASTMATH ? FastMath.acos(in) : Math.acos(in); case ATAN: return Math.atan(in); //faster in Math case CEIL: return FASTMATH ? FastMath.ceil(in) : Math.ceil(in); case FLOOR: return FASTMATH ? FastMath.floor(in) : Math.floor(in); case LOG: //if ( in <= 0 ) // throw new DMLRuntimeException("Builtin.execute(): logarithm can only be computed for non-negative numbers (input = " + in + ")."); // for negative numbers, Math.log will return NaN return FASTMATH ? FastMath.log(in) : Math.log(in); case LOG_NZ: return (in == 0) ? 0 : FASTMATH ? FastMath.log(in) : Math.log(in); case ABS: return Math.abs(in); //no need for FastMath case SQRT: //if ( in < 0 ) // throw new DMLRuntimeException("Builtin.execute(): squareroot can only be computed for non-negative numbers (input = " + in + ")."); return Math.sqrt(in); //faster in Math case PLOGP: if (in == 0.0) return 0.0; else if (in < 0) return Double.NaN; else return (in * (FASTMATH ? FastMath.log(in) : Math.log(in))); case EXP: return FASTMATH ? FastMath.exp(in) : Math.exp(in); case ROUND: return Math.round(in); //no need for FastMath case SPROP: //sample proportion: P*(1-P) return in * (1 - in); case SIGMOID: //sigmoid: 1/(1+exp(-x)) return FASTMATH ? 1 / (1 + FastMath.exp(-in)) : 1 / (1 + Math.exp(-in)); case SELP: //select positive: x*(x>0) return (in > 0) ? in : 0; default: throw new DMLRuntimeException("Builtin.execute(): Unknown operation: " + bFunc); } }
From source file:org.shensley.gtfs.FormatOutput.java
private double calcDistance(double vlat, double vlon, double slat, double slon) { double R = 6371000.0; // Earth's radius in metres. double dLat = (slat - vlat) * Math.PI / 180; double dLon = (slon - vlon) * Math.PI / 180; double a = 0.5 - Math.cos(dLat) / 2 + Math.cos(vlat * Math.PI / 180) * Math.cos(slat * Math.PI / 180) * (1 - Math.cos(dLon)) / 2; return R * 2 * Math.asin(Math.sqrt(a)); }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.util.tree.NumberArithmetic.java
/** * Returns the arc sine of the number.//from w ww . j a va 2 s .c o m * * @param a the number * @return the arc sine of the number * @see Math#asin(double) */ public static Number asin(Number a) { return Math.asin(a.doubleValue()); }
From source file:org.eclipse.smarthome.binding.astro.internal.calc.SunCalc.java
private double getSunDeclination(double lsun) { return Math.asin(Math.sin(lsun) * Math.sin(E)); }
From source file:org.eclipse.smarthome.binding.astro.internal.calc.SunCalc.java
private double getElevation(double th, double a, double phi, double d) { return Math.asin(Math.sin(phi) * Math.sin(d) + Math.cos(phi) * Math.cos(d) * Math.cos(th - a)); }
From source file:msi.gaml.operators.Maths.java
@operator(value = "asin", can_be_const = true, category = { IOperatorCategory.ARITHMETIC }) @doc(value = "Returns the value (in the interval [-90,90], in decimal degrees) of the arcsin of the operand (which should be in [-1,1]).", usages = { @usage(value = "if the right-hand operand is outside of the [-1,1] interval, returns NaN") }, examples = @example(value = "asin (0)", equals = "0.0"), see = { "acos", "atan", "sin" }) public static Double asin(final Double rv) { return Math.asin(rv) * toDeg; }