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

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

本文整理了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

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

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

@Override
 public double apply(double a) {
  return Math.asin(a);
 }
};

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

public float getInterpolation(float input) {
    if (input == 0) {
      return 0f;
    } else if (input == 1) {
      return 1f;
    }
    float p = 0.3f;
    float s = p / DOUBLE_PI * (float) Math.asin(1f);
    return -((float) Math.pow(2f, 10f * (input -= 1f))
        *(float) Math.sin((input - s) * DOUBLE_PI / p));
  }
};

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

public float getInterpolation(float input) {
    if (input == 0) {
      return 0f;
    } else if (input == 1) {
      return 1f;
    }
    float p = 0.3f;
    float s = p / DOUBLE_PI * (float) Math.asin(1f);
    return 1f
        + (float) Math.pow(2f, -10f * input)
        * (float) Math.sin((input - s) * DOUBLE_PI / p);
  }
};

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

public float getInterpolation(float input) {
    if (input == 0) {
      return 0f;
    }
    input *= 2f;
    if (input == 2) {
      return 1f;
    }
    float p = 1f / 0.45f;
    float s = 0.45f / DOUBLE_PI * (float) Math.asin(1f);
    if (input < 1f) {
      return -0.5f
          * ((float) Math.pow(2f, 10f * (input -= 1f))
          * (float) Math.sin((input * 1f - s) * DOUBLE_PI * p));
    }
    return 1f + 0.5f
        * (float) Math.pow(2f, -10f * (input -= 1f))
        * (float) Math.sin((input * 1f - s) * DOUBLE_PI * p);
  }
};

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

private static double compute() {
  double result = 0;
  for (int i = 0; i < 1000000; ++i) {
    result += Math.acos(Math.cos(i));
    result -= Math.asin(Math.sin(i));
  }
  return result;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 * Take Arc Sine of a in radians.
 */
@Override
protected DoubleWritable doEvaluate(DoubleWritable a) {
 double d = a.get();
 if (d < -1 || d > 1) {
  return null;
 } else {
  result.set(Math.asin(d));
  return result;
 }
}

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

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

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

public Coordinate getCoordinate()
 {
  return new Coordinate(Toolkit.radsToDegs(Math.asin(fY)),
   Toolkit.radsToDegs(Math.atan2(fX, fZ)));
 }
}

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

@Test
public void testAsin()
{
  for (double doubleValue : DOUBLE_VALUES) {
    assertFunction("asin(" + doubleValue + ")", DOUBLE, Math.asin(doubleValue));
    assertFunction("asin(REAL '" + (float) doubleValue + "')", DOUBLE, Math.asin((float) doubleValue));
  }
  assertFunction("asin(NULL)", DOUBLE, null);
}

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

@Description("arc sine")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double asin(@SqlType(StandardTypes.DOUBLE) double num)
{
  return Math.asin(num);
}

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

public Value asin() throws KettleValueException {
 if ( isNull() ) {
  return this;
 }
 if ( isNumeric() ) {
  setValue( Math.asin( getNumber() ) );
 } else {
  throw new KettleValueException( "Function ASIN only works with numeric data" );
 }
 return this;
}

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

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

相关文章