Tabnine Logo
Math.toDegrees
Code IndexAdd Tabnine to your IDE (free)

How to use
toDegrees
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.toDegrees (Showing top 20 results out of 5,166)

origin: google/ExoPlayer

 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;
  }
 }
}
origin: stackoverflow.com

 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;
}
origin: libgdx/libgdx

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]);
}
origin: libgdx/libgdx

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]);
}
origin: Yalantis/uCrop

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))));
}
origin: apache/incubator-druid

 @Override
 protected ExprEval eval(double param)
 {
  return ExprEval.of(Math.toDegrees(param));
 }
}
origin: prestodb/presto

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;
}
origin: PhilJay/MPAndroidChart

/**
 * 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;
}
origin: prestodb/presto

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;
}
origin: MovingBlocks/Terasology

@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;
}
origin: google/j2objc

public static @degrees double toDegrees(@radians double angrad) { return Math.toDegrees(angrad); }
origin: apache/hive

@Override
protected DoubleWritable doEvaluate(DoubleWritable a) {
 result.set(Math.toDegrees(a.get()));
 return result;
}
origin: google/ExoPlayer

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;
}
origin: neo4j/neo4j

public static DoubleValue toDegrees( AnyValue in )
{
  if ( in instanceof NumberValue )
  {
    return doubleValue( Math.toDegrees( ((NumberValue) in).doubleValue() ) );
  }
  else
  {
    throw needsNumbers( "toDegrees()" );
  }
}
origin: prestodb/presto

@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);
}
origin: google/ExoPlayer

 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);
  }
 }
}
origin: prestodb/presto

@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);
}
origin: jfoenixadmin/JFoenix

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));
  }
}
origin: libgdx/libgdx

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();
}
origin: apache/hive

@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]);
}
java.langMathtoDegrees

Javadoc

Returns the measure in degrees of the supplied radian angle. The result is angrad * 180 / pi.

Special cases:

  • toDegrees(+0.0) = +0.0
  • toDegrees(-0.0) = -0.0
  • toDegrees(+infinity) = +infinity
  • toDegrees(-infinity) = -infinity
  • toDegrees(NaN) = NaN

Popular methods of Math

  • min
    Returns the smaller of two long values. That is, the result is the argument closer to the value of L
  • max
    Returns the greater of two long values. That is, the result is the argument closer to the value of L
  • abs
    Returns the absolute value of a long value. If the argument is not negative, the argument is returne
  • round
    Returns the closest int to the argument, with ties rounding up. Special cases: * If the argument is
  • pow
    Returns the value of the first argument raised to the power of the second argument. Special cases: *
  • sqrt
    Returns the correctly rounded positive square root of a double value. Special cases: * If the argume
  • ceil
    Returns the smallest (closest to negative infinity) double value that is greater than or equal to th
  • floor
    Returns the largest (closest to positive infinity) double value that is less than or equal to the ar
  • random
    Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returne
  • sin
    Returns the trigonometric sine of an angle. Special cases: * If the argument is NaN or an infinit
  • cos
    Returns the trigonometric cosine of an angle. Special cases: * If the argument is NaN or an infin
  • log
    Returns the natural logarithm (base e) of a doublevalue. Special cases: * If the argument is NaN
  • cos,
  • log,
  • exp,
  • toRadians,
  • atan2,
  • log10,
  • acos,
  • tan,
  • atan

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JLabel (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now