private float calculateFieldOfViewInYDirection(float aspect) { boolean landscapeMode = aspect > 1; if (landscapeMode) { double halfFovX = FIELD_OF_VIEW_DEGREES / 2; double tanY = Math.tan(Math.toRadians(halfFovX)) / aspect; double halfFovY = Math.toDegrees(Math.atan(tanY)); return (float) (halfFovY * 2); } else { return FIELD_OF_VIEW_DEGREES; } } }
public float getAngle(Point target) { float angle = (float) Math.toDegrees(Math.atan2(target.y - y, target.x - x)); if(angle < 0){ angle += 360; } return angle; }
private void updateOrientation () { if (rotationVectorAvailable){ SensorManager.getRotationMatrixFromVector(R, rotationVectorValues); } else if (!SensorManager.getRotationMatrix(R, null, accelerometerValues, magneticFieldValues)) { return; // compass + accelerometer in free fall } SensorManager.getOrientation(R, orientation); azimuth = (float)Math.toDegrees(orientation[0]); pitch = (float)Math.toDegrees(orientation[1]); roll = (float)Math.toDegrees(orientation[2]); }
private void updateOrientation () { if (rotationVectorAvailable){ SensorManager.getRotationMatrixFromVector(R, rotationVectorValues); } else if (!SensorManager.getRotationMatrix(R, null, accelerometerValues, magneticFieldValues)) { return; // compass + accelerometer in free fall } SensorManager.getOrientation(R, orientation); azimuth = (float)Math.toDegrees(orientation[0]); pitch = (float)Math.toDegrees(orientation[1]); roll = (float)Math.toDegrees(orientation[2]); }
private float calculateAngleBetweenLines(float fx1, float fy1, float fx2, float fy2, float sx1, float sy1, float sx2, float sy2) { return calculateAngleDelta( (float) Math.toDegrees((float) Math.atan2((fy1 - fy2), (fx1 - fx2))), (float) Math.toDegrees((float) Math.atan2((sy1 - sy2), (sx1 - sx2)))); }
@Override protected ExprEval eval(double param) { return ExprEval.of(Math.toDegrees(param)); } }
private static double addDistanceToLatitude( @SqlType(StandardTypes.DOUBLE) double latitude, @SqlType(StandardTypes.DOUBLE) double radiusInKm, @SqlType(StandardTypes.DOUBLE) double bearing) { double latitudeInRadians = toRadians(latitude); double bearingInRadians = toRadians(bearing); double radiusRatio = radiusInKm / EARTH_RADIUS_KM; // Haversine formula double newLatitude = toDegrees(asin(sin(latitudeInRadians) * cos(radiusRatio) + cos(latitudeInRadians) * sin(radiusRatio) * cos(bearingInRadians))); if (newLatitude > MAX_LATITUDE) { return MAX_LATITUDE; } if (newLatitude < MIN_LATITUDE) { return MIN_LATITUDE; } return newLatitude; }
/** * returns the angle relative to the chart center for the given point on the * chart in degrees. The angle is always between 0 and 360°, 0° is NORTH, * 90° is EAST, ... * * @param x * @param y * @return */ public float getAngleForPoint(float x, float y) { MPPointF c = getCenterOffsets(); double tx = x - c.x, ty = y - c.y; double length = Math.sqrt(tx * tx + ty * ty); double r = Math.acos(ty / length); float angle = (float) Math.toDegrees(r); if (x > c.x) angle = 360f - angle; // add 90° because chart starts EAST angle = angle + 90f; // neutralize overflow if (angle > 360f) angle = angle - 360f; MPPointF.recycleInstance(c); return angle; }
private static double addDistanceToLongitude( @SqlType(StandardTypes.DOUBLE) double latitude, @SqlType(StandardTypes.DOUBLE) double longitude, @SqlType(StandardTypes.DOUBLE) double radiusInKm, @SqlType(StandardTypes.DOUBLE) double bearing) { double latitudeInRadians = toRadians(latitude); double longitudeInRadians = toRadians(longitude); double bearingInRadians = toRadians(bearing); double radiusRatio = radiusInKm / EARTH_RADIUS_KM; // Haversine formula double newLongitude = toDegrees(longitudeInRadians + atan2(sin(bearingInRadians) * sin(radiusRatio) * cos(latitudeInRadians), cos(radiusRatio) - sin(latitudeInRadians) * sin(latitudeInRadians))); if (newLongitude > MAX_LONGITUDE) { return MIN_LONGITUDE + (newLongitude - MAX_LONGITUDE); } if (newLongitude < MIN_LONGITUDE) { return MAX_LONGITUDE + (newLongitude - MIN_LONGITUDE); } return newLongitude; }
@Override public float getDaylight() { float angle = (float) Math.toDegrees(TeraMath.clamp(Math.cos(getSunPositionAngle()))); float daylight = 1.0f; if (angle < 24.0f) { daylight = 1.0f - (24.0f - angle) / 24.0f; } return daylight; }
public static @degrees double toDegrees(@radians double angrad) { return Math.toDegrees(angrad); }
@Override protected DoubleWritable doEvaluate(DoubleWritable a) { result.set(Math.toDegrees(a.get())); return result; }
private static float[] createRotationMatrix(float angleRadian, int x, int y, int z) { float[] expectedMatrix = new float[16]; Matrix.setRotateM(expectedMatrix, 0, (float) Math.toDegrees(angleRadian), x, y, z); return expectedMatrix; }
public static DoubleValue toDegrees( AnyValue in ) { if ( in instanceof NumberValue ) { return doubleValue( Math.toDegrees( ((NumberValue) in).doubleValue() ) ); } else { throw needsNumbers( "toDegrees()" ); } }
@Test public void testDegrees() { for (double doubleValue : DOUBLE_VALUES) { assertFunction(String.format("degrees(%s)", doubleValue), DOUBLE, Math.toDegrees(doubleValue)); assertFunction(String.format("degrees(REAL '%s')", (float) doubleValue), DOUBLE, Math.toDegrees((float) doubleValue)); } assertFunction("degrees(NULL)", DOUBLE, null); }
private static void getRotationMatrixFromAngleAxis(float[] matrix, float[] angleAxis) { // Convert coordinates to OpenGL coordinates. // CAMM motion metadata: +x right, +y down, and +z forward. // OpenGL: +x right, +y up, -z forwards float x = angleAxis[0]; float y = -angleAxis[1]; float z = -angleAxis[2]; float angleRad = Matrix.length(x, y, z); if (angleRad != 0) { float angleDeg = (float) Math.toDegrees(angleRad); Matrix.setRotateM(matrix, 0, angleDeg, x / angleRad, y / angleRad, z / angleRad); } else { Matrix.setIdentityM(matrix, 0); } } }
@Description("converts an angle in radians to degrees") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double degrees(@SqlType(StandardTypes.DOUBLE) double radians) { return Math.toDegrees(radians); }
private void goToTime(LocalTime time) { if (time != null) { int hour = time.getHour(); selectedHourLabel.setText(Integer.toString(hour % (is24HourView ? 24 : 12) == 0 ? (is24HourView ? 0 : 12) : hour % (is24HourView ? 24 : 12))); selectedMinLabel.setText(unitConverter.toString(time.getMinute())); if (!is24HourView) { period.set(hour < 12 ? "AM" : "PM"); } minsPointerRotate.setAngle(180 + (time.getMinute() + 45) % 60 * Math.toDegrees(2 * Math.PI / 60)); hoursPointerRotate.setAngle(180 + Math.toDegrees(2 * (hour - 3) * Math.PI / 12)); _24HourHoursPointerRotate.setAngle(180 + Math.toDegrees(2 * (hour - 3) * Math.PI / 12)); } }
private void renderBox (Body body, float halfWidth, float halfHeight) { // get the bodies center and angle in world coordinates Vector2 pos = body.getWorldCenter(); float angle = body.getAngle(); // set the translation and rotation matrix transform.setToTranslation(pos.x, pos.y, 0); transform.rotate(0, 0, 1, (float)Math.toDegrees(angle)); // render the box renderer.begin(ShapeType.Line); renderer.setTransformMatrix(transform); renderer.setColor(1, 1, 1, 1); renderer.rect(-halfWidth, -halfHeight, halfWidth * 2, halfHeight * 2); renderer.end(); }
@Test public void testVectorDegrees() throws HiveException { VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut(); DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1]; b.cols[0].noNulls = true; VectorExpression expr = new FuncDegreesDoubleToDouble(0, 1); expr.evaluate(b); Assert.assertEquals(Math.toDegrees(0.5d), resultV.vector[4]); }