public float getInterpolation(float input) { return -(float) Math.cos(input * (Math.PI / 2f)) + 1f; } };
public static double cos(double a){ return Math.cos(a); }
public float getInterpolation(float input) { return -0.5f * ((float) Math.cos(Math.PI * input) - 1f); } };
/** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param radians the angle in radians */ public Vector2 rotateRad (float radians) { float cos = (float)Math.cos(radians); float sin = (float)Math.sin(radians); float newX = this.x * cos - this.y * sin; float newY = this.x * sin + this.y * cos; this.x = newX; this.y = newY; return this; }
/** Sets the rotation of this transform * @param angle angle in radians */ public void setRotation (float angle) { float c = (float)Math.cos(angle), s = (float)Math.sin(angle); vals[COS] = c; vals[SIN] = s; }
/** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param radians the angle in radians */ public Vector2 rotateRad (float radians) { float cos = (float)Math.cos(radians); float sin = (float)Math.sin(radians); float newX = this.x * cos - this.y * sin; float newY = this.x * sin + this.y * cos; this.x = newX; this.y = newY; return this; }
/** Sets the rotation of this transform * @param angle angle in radians */ public void setRotation (float angle) { float c = (float)Math.cos(angle), s = (float)Math.sin(angle); vals[COS] = c; vals[SIN] = s; }
public static void getPosition(MPPointF center, float dist, float angle, MPPointF outputPoint){ outputPoint.x = (float) (center.x + dist * Math.cos(Math.toRadians(angle))); outputPoint.y = (float) (center.y + dist * Math.sin(Math.toRadians(angle))); }
public void getPosition(MPPointF center, float dist, float angle, MPPointF outputPoint) { outputPoint.x = (float) (center.x + dist * Math.cos(Math.toRadians(angle))); outputPoint.y = (float) (center.y + dist * Math.sin(Math.toRadians(angle))); }
var rad = function(x) { return x * Math.PI / 180; }; var getDistance = function(p1, p2) { var R = 6378137; // Earth’s mean radius in meter var dLat = rad(p2.lat() - p1.lat()); var dLong = rad(p2.lng() - p1.lng()); var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * Math.sin(dLong / 2) * Math.sin(dLong / 2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); var d = R * c; return d; // returns the distance in meter };
private GreatCircleDistanceToPoint(double latitude, double longitude) { double radianLatitude = toRadians(latitude); this.sinLatitude = sin(radianLatitude); this.cosLatitude = cos(radianLatitude); this.radianLongitude = toRadians(longitude); }
public double distance(double latitude2, double longitude2) { double radianLatitude2 = toRadians(latitude2); double sin2 = sin(radianLatitude2); double cos2 = cos(radianLatitude2); double deltaLongitude = radianLongitude - toRadians(longitude2); double cosDeltaLongitude = cos(deltaLongitude); double t1 = cos2 * sin(deltaLongitude); double t2 = cosLatitude * sin2 - sinLatitude * cos2 * cosDeltaLongitude; double t3 = sinLatitude * sin2 + cosLatitude * cos2 * cosDeltaLongitude; return atan2(sqrt(t1 * t1 + t2 * t2), t3) * EARTH_RADIUS_KM; } }
public static float distFrom(float lat1, float lng1, float lat2, float lng2) { double earthRadius = 6371000; //meters double dLat = Math.toRadians(lat2-lat1); double dLng = Math.toRadians(lng2-lng1); double a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLng/2) * Math.sin(dLng/2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); float dist = (float) (earthRadius * c); return dist; }
@Override protected ExprEval eval(double param) { return ExprEval.of(Math.cos(param)); } }
/** Sets the quaternion components from the given axis and angle around that axis. * @param x X direction of the axis * @param y Y direction of the axis * @param z Z direction of the axis * @param radians The angle in radians * @return This quaternion for chaining. */ public Quaternion setFromAxisRad (final float x, final float y, final float z, final float radians) { float d = Vector3.len(x, y, z); if (d == 0f) return idt(); d = 1f / d; float l_ang = radians < 0 ? MathUtils.PI2 - (-radians % MathUtils.PI2) : radians % MathUtils.PI2; float l_sin = (float)Math.sin(l_ang / 2); float l_cos = (float)Math.cos(l_ang / 2); return this.set(d * x * l_sin, d * y * l_sin, d * z * l_sin, l_cos).nor(); }
/** Sets the quaternion components from the given axis and angle around that axis. * @param x X direction of the axis * @param y Y direction of the axis * @param z Z direction of the axis * @param radians The angle in radians * @return This quaternion for chaining. */ public Quaternion setFromAxisRad (final float x, final float y, final float z, final float radians) { float d = Vector3.len(x, y, z); if (d == 0f) return idt(); d = 1f / d; float l_ang = radians < 0 ? MathUtils.PI2 - (-radians % MathUtils.PI2) : radians % MathUtils.PI2; float l_sin = (float)Math.sin(l_ang / 2); float l_cos = (float)Math.cos(l_ang / 2); return this.set(d * x * l_sin, d * y * l_sin, d * z * l_sin, l_cos).nor(); }
@Description("cosine") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double cos(@SqlType(StandardTypes.DOUBLE) double num) { return Math.cos(num); }
private void drawSolidCircle (Vector2 center, float radius, Vector2 axis, Color color) { float angle = 0; float angleInc = 2 * (float)Math.PI / 20; renderer.setColor(color.r, color.g, color.b, color.a); for (int i = 0; i < 20; i++, angle += angleInc) { v.set((float)Math.cos(angle) * radius + center.x, (float)Math.sin(angle) * radius + center.y); if (i == 0) { lv.set(v); f.set(v); continue; } renderer.line(lv.x, lv.y, v.x, v.y); lv.set(v); } renderer.line(f.x, f.y, lv.x, lv.y); renderer.line(center.x, center.y, 0, center.x + axis.x * radius, center.y + axis.y * radius, 0); }
private void drawSolidCircle (Vector2 center, float radius, Vector2 axis, Color color) { float angle = 0; float angleInc = 2 * (float)Math.PI / 20; renderer.setColor(color.r, color.g, color.b, color.a); for (int i = 0; i < 20; i++, angle += angleInc) { v.set((float)Math.cos(angle) * radius + center.x, (float)Math.sin(angle) * radius + center.y); if (i == 0) { lv.set(v); f.set(v); continue; } renderer.line(lv.x, lv.y, v.x, v.y); lv.set(v); } renderer.line(f.x, f.y, lv.x, lv.y); renderer.line(center.x, center.y, 0, center.x + axis.x * radius, center.y + axis.y * radius, 0); }