java.lang.Math.toRadians()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(209)

本文整理了Java中java.lang.Math.toRadians()方法的一些代码示例,展示了Math.toRadians()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Math.toRadians()方法的具体详情如下:
包路径:java.lang.Math
类名称:Math
方法名:toRadians

Math.toRadians介绍

[英]Returns the measure in radians of the supplied degree angle. The result is angdeg / 180 * pi.

Special cases:

  • toRadians(+0.0) = +0.0
  • toRadians(-0.0) = -0.0
  • toRadians(+infinity) = +infinity
  • toRadians(-infinity) = -infinity
  • toRadians(NaN) = NaN
    [中]返回提供的度角的弧度度量值。结果为angdeg/180*pi。
    特殊情况:
    *环面(+0.0)=+0.0
    *环面(-0.0)=-0.0
    *环面(+无穷大)=+无穷大
    *环面半径(-无穷大)=-无穷大
    *托拉第安(NaN)=NaN

代码示例

代码示例来源:origin: scwang90/SmartRefreshLayout

float getMinProgressArc(Ring ring) {
  return (float) Math.toRadians(
      ring.mStrokeWidth / (2 * Math.PI * ring.mRingCenterRadius));
}

代码示例来源:origin: PhilJay/MPAndroidChart

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)));
}

代码示例来源:origin: PhilJay/MPAndroidChart

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)));
}

代码示例来源:origin: prestodb/presto

private GreatCircleDistanceToPoint(double latitude, double longitude)
{
  double radianLatitude = toRadians(latitude);
  this.sinLatitude = sin(radianLatitude);
  this.cosLatitude = cos(radianLatitude);
  this.radianLongitude = toRadians(longitude);
}

代码示例来源:origin: stackoverflow.com

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;
 }

代码示例来源:origin: nickbutcher/plaid

private static float toTangent(float arcInDegrees) {
  if (arcInDegrees < 0 || arcInDegrees > 90) {
    throw new IllegalArgumentException("Arc must be between 0 and 90 degrees");
  }
  return (float) Math.tan(Math.toRadians(arcInDegrees / 2));
}

代码示例来源:origin: stackoverflow.com

public static double distFrom(double lat1, double lng1, double lat2, double lng2) {
 double earthRadius = 3958.75; // miles (or 6371.0 kilometers)
 double dLat = Math.toRadians(lat2-lat1);
 double dLng = Math.toRadians(lng2-lng1);
 double sindLat = Math.sin(dLat / 2);
 double sindLng = Math.sin(dLng / 2);
 double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2)
     * Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2));
 double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
 double dist = earthRadius * c;
 return dist;
 }

代码示例来源:origin: prestodb/presto

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;
  }
}

代码示例来源: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: apache/incubator-druid

@Override
 protected ExprEval eval(double param)
 {
  return ExprEval.of(Math.toRadians(param));
 }
}

代码示例来源:origin: robolectric/robolectric

public static SimpleMatrix rotate(float degrees) {
 final double radians = Math.toRadians(degrees);
 final float sin = (float) Math.sin(radians);
 final float cos = (float) Math.cos(radians);
 return sinCos(sin, cos);
}

代码示例来源:origin: robolectric/robolectric

public static SimpleMatrix rotate(float degrees, float px, float py) {
 final double radians = Math.toRadians(degrees);
 final float sin = (float) Math.sin(radians);
 final float cos = (float) Math.cos(radians);
 return sinCos(sin, cos, px, py);
}

代码示例来源:origin: openhab/openhab1-addons

public DecimalType getGravity() {
  double latRad = Math.toRadians(latitude.doubleValue());
  double deltaG = -2000.0 * (altitude.doubleValue() / 1000) * EARTH_GRAVITATIONAL_CONSTANT
      / (Math.pow(WGS84_a, 3.0));
  double sin2lat = Math.sin(latRad) * Math.sin(latRad);
  double sin22lat = Math.sin(2.0 * latRad) * Math.sin(2.0 * latRad);
  double result = (9.780327 * (1.0 + 5.3024e-3 * sin2lat - 5.8e-6 * sin22lat) + deltaG);
  return new DecimalType(result);
}

代码示例来源: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: google/j2objc

public static @radians double toRadians(@degrees double angdeg) { return Math.toRadians(angdeg); }
public static @degrees double toDegrees(@radians double angrad) { return Math.toDegrees(angrad); }

代码示例来源:origin: neo4j/neo4j

public static DoubleValue toRadians( AnyValue in )
{
  if ( in instanceof NumberValue )
  {
    return doubleValue( Math.toRadians( ((NumberValue) in).doubleValue() ) );
  }
  else
  {
    throw needsNumbers( "toRadians()" );
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testRadians()
{
  for (double doubleValue : DOUBLE_VALUES) {
    assertFunction(String.format("radians(%s)", doubleValue), DOUBLE, Math.toRadians(doubleValue));
    assertFunction(String.format("radians(REAL '%s')", (float) doubleValue), DOUBLE, Math.toRadians((float) doubleValue));
  }
  assertFunction("radians(NULL)", DOUBLE, null);
}

代码示例来源:origin: prestodb/presto

@Description("converts an angle in degrees to radians")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double radians(@SqlType(StandardTypes.DOUBLE) double degrees)
{
  return Math.toRadians(degrees);
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
protected float[] getMarkerPosition(Highlight highlight) {
  MPPointF center = getCenterCircleBox();
  float r = getRadius();
  float off = r / 10f * 3.6f;
  if (isDrawHoleEnabled()) {
    off = (r - (r / 100f * getHoleRadius())) / 2f;
  }
  r -= off; // offset to keep things inside the chart
  float rotationAngle = getRotationAngle();
  int entryIndex = (int) highlight.getX();
  // offset needed to center the drawn text in the slice
  float offset = mDrawAngles[entryIndex] / 2;
  // calculate the text position
  float x = (float) (r
      * Math.cos(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
      * mAnimator.getPhaseY())) + center.x);
  float y = (float) (r
      * Math.sin(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
      * mAnimator.getPhaseY())) + center.y);
  MPPointF.recycleInstance(center);
  return new float[]{x, y};
}

代码示例来源:origin: MovingBlocks/Terasology

public static TreeGenerator oakTree() {
  return new TreeGeneratorLSystem(
    "FFFFFFA", ImmutableMap.<Character, LSystemRule>builder()
    .put('A', new LSystemRule("[&FFBFA]////[&BFFFA]////[&FBFFA]", 1.0f))
    .put('B', new LSystemRule("[&FFFA]////[&FFFA]////[&FFFA]", 0.8f)).build(),
    4, (float) Math.toRadians(30))
    .setLeafType(new BlockUri("core:GreenLeaf"))
    .setBarkType(new BlockUri("core:OakTrunk"));
}

相关文章