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

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

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

Math.asin介绍

[英]Returns the closest double approximation of the arc sine of the argument within the range [-pi/2..pi/2]. The returned result is within 1 ulp (unit in the last place) of the real result.

Special cases:

  • asin((anything > 1)) = NaN
  • asin((anything < -1)) = NaN
  • asin(NaN) = NaN
    [中]返回[-pi/2..pi/2]范围内参数弧正弦的最接近的双近似值。返回的结果在实际结果的1 ulp(最后一位的单位)范围内。
    特殊情况:
    *asin((任何>1))=NaN
    *asin((任何事物<-1))=NaN
    *asin(NaN)=NaN

代码示例

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

  1. /**
  2. * 获得两个圆切线与圆心连线的夹角
  3. * @return 夹角
  4. */
  5. private double getAngle() {
  6. if (bottomCircle.radius > topCircle.radius) {
  7. // throw new IllegalStateException("bottomCircle's radius must be less than the topCircle's");
  8. return 0;
  9. }
  10. return Math.asin((topCircle.radius - bottomCircle.radius) / (bottomCircle.y - topCircle.y));
  11. }

代码示例来源:origin: apache/mahout

  1. @Override
  2. public double apply(double a) {
  3. return Math.asin(a);
  4. }
  5. };

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

  1. public float getInterpolation(float input) {
  2. if (input == 0) {
  3. return 0f;
  4. } else if (input == 1) {
  5. return 1f;
  6. }
  7. float p = 0.3f;
  8. float s = p / DOUBLE_PI * (float) Math.asin(1f);
  9. return -((float) Math.pow(2f, 10f * (input -= 1f))
  10. *(float) Math.sin((input - s) * DOUBLE_PI / p));
  11. }
  12. };

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

  1. public float getInterpolation(float input) {
  2. if (input == 0) {
  3. return 0f;
  4. } else if (input == 1) {
  5. return 1f;
  6. }
  7. float p = 0.3f;
  8. float s = p / DOUBLE_PI * (float) Math.asin(1f);
  9. return 1f
  10. + (float) Math.pow(2f, -10f * input)
  11. * (float) Math.sin((input - s) * DOUBLE_PI / p);
  12. }
  13. };

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

  1. public float getInterpolation(float input) {
  2. if (input == 0) {
  3. return 0f;
  4. }
  5. input *= 2f;
  6. if (input == 2) {
  7. return 1f;
  8. }
  9. float p = 1f / 0.45f;
  10. float s = 0.45f / DOUBLE_PI * (float) Math.asin(1f);
  11. if (input < 1f) {
  12. return -0.5f
  13. * ((float) Math.pow(2f, 10f * (input -= 1f))
  14. * (float) Math.sin((input * 1f - s) * DOUBLE_PI * p));
  15. }
  16. return 1f + 0.5f
  17. * (float) Math.pow(2f, -10f * (input -= 1f))
  18. * (float) Math.sin((input * 1f - s) * DOUBLE_PI * p);
  19. }
  20. };

代码示例来源:origin: markzhai/AndroidPerformanceMonitor

  1. private static double compute() {
  2. double result = 0;
  3. for (int i = 0; i < 1000000; ++i) {
  4. result += Math.acos(Math.cos(i));
  5. result -= Math.asin(Math.sin(i));
  6. }
  7. return result;
  8. }

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

  1. /**
  2. * @return Latitude (-PI/2 to PI/2), projected from center of Earth on
  3. * y axis with a twist and a log scale.
  4. */
  5. public double projectY(double pY)
  6. {
  7. return (pY >= 0.9999999999) ? 1e6
  8. : (pY <= -0.9999999999) ? -1e6
  9. : Math.log(Math.tan(Math.asin(pY) / 2 + Math.PI / 4));
  10. }

代码示例来源:origin: apache/incubator-druid

  1. @Override
  2. protected ExprEval eval(double param)
  3. {
  4. return ExprEval.of(Math.asin(param));
  5. }
  6. }

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

  1. public BigDecimal eval(List<? extends Number> parameters) {
  2. assertNotNull(parameters.get(0));
  3. double d = Math.toDegrees(Math.asin(parameters.get(0).doubleValue()));
  4. return new BigDecimal(d, mc);
  5. }
  6. });

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

  1. /**
  2. * Calculates distance of (from, to) in meter.
  3. * <p>
  4. * http://en.wikipedia.org/wiki/Haversine_formula a = sin²(Δlat/2) +
  5. * cos(lat1).cos(lat2).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c
  6. */
  7. @Override
  8. public double calcDist(double fromLat, double fromLon, double toLat, double toLon) {
  9. double normedDist = calcNormalizedDist(fromLat, fromLon, toLat, toLon);
  10. return R * 2 * asin(sqrt(normedDist));
  11. }

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

  1. /** Get the pitch euler angle in radians, which is the rotation around the x axis. Requires that this quaternion is normalized.
  2. * @return the rotation around the x axis in radians (between -(PI/2) and +(PI/2)) */
  3. public float getPitchRad () {
  4. final int pole = getGimbalPole();
  5. return pole == 0 ? (float)Math.asin(MathUtils.clamp(2f * (w * x - z * y), -1f, 1f)) : (float)pole * MathUtils.PI * 0.5f;
  6. }

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

  1. /** Get the pitch euler angle in radians, which is the rotation around the x axis. Requires that this quaternion is normalized.
  2. * @return the rotation around the x axis in radians (between -(PI/2) and +(PI/2)) */
  3. public float getPitchRad () {
  4. final int pole = getGimbalPole();
  5. return pole == 0 ? (float)Math.asin(MathUtils.clamp(2f * (w * x - z * y), -1f, 1f)) : (float)pole * MathUtils.PI * 0.5f;
  6. }

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

  1. private static double addDistanceToLatitude(
  2. @SqlType(StandardTypes.DOUBLE) double latitude,
  3. @SqlType(StandardTypes.DOUBLE) double radiusInKm,
  4. @SqlType(StandardTypes.DOUBLE) double bearing)
  5. {
  6. double latitudeInRadians = toRadians(latitude);
  7. double bearingInRadians = toRadians(bearing);
  8. double radiusRatio = radiusInKm / EARTH_RADIUS_KM;
  9. // Haversine formula
  10. double newLatitude = toDegrees(asin(sin(latitudeInRadians) * cos(radiusRatio) +
  11. cos(latitudeInRadians) * sin(radiusRatio) * cos(bearingInRadians)));
  12. if (newLatitude > MAX_LATITUDE) {
  13. return MAX_LATITUDE;
  14. }
  15. if (newLatitude < MIN_LATITUDE) {
  16. return MIN_LATITUDE;
  17. }
  18. return newLatitude;
  19. }

代码示例来源:origin: apache/hive

  1. /**
  2. * Take Arc Sine of a in radians.
  3. */
  4. @Override
  5. protected DoubleWritable doEvaluate(DoubleWritable a) {
  6. double d = a.get();
  7. if (d < -1 || d > 1) {
  8. return null;
  9. } else {
  10. result.set(Math.asin(d));
  11. return result;
  12. }
  13. }

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

  1. public static DoubleValue asin( AnyValue in )
  2. {
  3. if ( in instanceof NumberValue )
  4. {
  5. return doubleValue( Math.asin( ((NumberValue) in).doubleValue() ) );
  6. }
  7. else
  8. {
  9. throw needsNumbers( "asin()" );
  10. }
  11. }

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

  1. public Coordinate getCoordinate()
  2. {
  3. return new Coordinate(Toolkit.radsToDegs(Math.asin(fY)),
  4. Toolkit.radsToDegs(Math.atan2(fX, fZ)));
  5. }
  6. }

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

  1. @Test
  2. public void testAsin()
  3. {
  4. for (double doubleValue : DOUBLE_VALUES) {
  5. assertFunction("asin(" + doubleValue + ")", DOUBLE, Math.asin(doubleValue));
  6. assertFunction("asin(REAL '" + (float) doubleValue + "')", DOUBLE, Math.asin((float) doubleValue));
  7. }
  8. assertFunction("asin(NULL)", DOUBLE, null);
  9. }

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

  1. @Description("arc sine")
  2. @ScalarFunction
  3. @SqlType(StandardTypes.DOUBLE)
  4. public static double asin(@SqlType(StandardTypes.DOUBLE) double num)
  5. {
  6. return Math.asin(num);
  7. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public Value asin() throws KettleValueException {
  2. if ( isNull() ) {
  3. return this;
  4. }
  5. if ( isNumeric() ) {
  6. setValue( Math.asin( getNumber() ) );
  7. } else {
  8. throw new KettleValueException( "Function ASIN only works with numeric data" );
  9. }
  10. return this;
  11. }

代码示例来源:origin: apache/hive

  1. @Test
  2. public void testVectorASin() throws HiveException {
  3. VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut();
  4. DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1];
  5. b.cols[0].noNulls = true;
  6. VectorExpression expr = new FuncASinDoubleToDouble(0, 1);
  7. expr.evaluate(b);
  8. Assert.assertEquals(Math.asin(0.5d), resultV.vector[4]);
  9. }

相关文章