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

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

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

Math.tan介绍

[英]Returns the closest double approximation of the tangent of the argument. The returned result is within 1 ulp (unit in the last place) of the real result.

Special cases:

  • tan(+0.0) = +0.0
  • tan(-0.0) = -0.0
  • tan(+infinity) = NaN
  • tan(-infinity) = NaN
  • tan(NaN) = NaN
    [中]返回参数切线的最接近的双近似值。返回的结果在实际结果的1 ulp(最后一位的单位)范围内。
    特殊情况:
    *tan(+0.0)=+0.0
    *tan(-0.0)=-0.0
    *谭(+无限)=南
    *tan(-无穷大)=NaN
    *谭(南)=南

代码示例

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

public static float[] createPerspectiveMatrix (int fieldOfViewVertical, float aspectRatio, float minimumClearance,
  float maximumClearance) {
  double fieldOfViewInRad = fieldOfViewVertical * Math.PI / 180.0;
  return new float[] {(float)(Math.tan(fieldOfViewInRad) / aspectRatio), 0, 0, 0, 0,
    (float)(1 / Math.tan(fieldOfViewVertical * Math.PI / 180.0)), 0, 0, 0, 0,
    (minimumClearance + maximumClearance) / (minimumClearance - maximumClearance), -1, 0, 0,
    2 * minimumClearance * maximumClearance / (minimumClearance - maximumClearance), 0};
}

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

public static float[] createPerspectiveMatrix (int fieldOfViewVertical, float aspectRatio, float minimumClearance,
  float maximumClearance) {
  double fieldOfViewInRad = fieldOfViewVertical * Math.PI / 180.0;
  return new float[] {(float)(Math.tan(fieldOfViewInRad) / aspectRatio), 0, 0, 0, 0,
    (float)(1 / Math.tan(fieldOfViewVertical * Math.PI / 180.0)), 0, 0, 0, 0,
    (minimumClearance + maximumClearance) / (minimumClearance - maximumClearance), -1, 0, 0,
    2 * minimumClearance * maximumClearance / (minimumClearance - maximumClearance), 0};
}

代码示例来源:origin: Bilibili/DanmakuFlameMaster

@Override
public void setSize(int width, int height) {
  this.width = width;
  this.height = height;
  this.locationZ = (float) (width / 2f / Math.tan((Math.PI / 180) * (55f / 2f)));
}

代码示例来源: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: 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: andkulikov/Transitions-Everywhere

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: apache/incubator-druid

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

代码示例来源:origin: kevin-wayne/algs4

/**
 * Returns a random real number from the Cauchy distribution.
 *
 * @return a random real number from the Cauchy distribution.
 */
public static double cauchy() {
  return Math.tan(Math.PI * (uniform() - 0.5));
}

代码示例来源:origin: guoguibing/librec

/**
 * Return a real number with a Cauchy distribution.
 *
 * @return a real number with a Cauchy distribution
 */
public static double cauchy() {
  return Math.tan(Math.PI * (uniform() - 0.5));
}

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

Camera.Parameters p = camera.getParameters();
int zoom = p.getZoomRatios().get(p.getZoom()).intValue();
Camera.Size sz = p.getPreviewSize();
double aspect = (double) sz.width / (double) sz.height;
double thetaV = Math.toRadians(p.getVerticalViewAngle());
double thetaH = 2d * Math.atan(aspect * Math.tan(thetaV / 2));
thetaV = 2d * Math.atan(100d * Math.tan(thetaV / 2d) / zoom);
thetaH = 2d * Math.atan(100d * Math.tan(thetaH / 2d) / zoom);

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

/**
 * Take Tangent of a
 */
@Override
protected DoubleWritable doEvaluate(DoubleWritable a) {
 result.set(Math.tan(a.get()));
 return result;
}

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

private static Matrix4f createPerspectiveProjectionMatrix(float fov, float zNear, float zFar) {
  float aspectRatio = (float) Display.getWidth() / Display.getHeight();
  float fovY = (float) (2 * Math.atan2(Math.tan(0.5 * fov * TeraMath.DEG_TO_RAD), aspectRatio));
  return MatrixUtils.createPerspectiveProjectionMatrix(fovY, aspectRatio, zNear, zFar);
}

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

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

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

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

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

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

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

@Description("tangent")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double tan(@SqlType(StandardTypes.DOUBLE) double num)
{
  return Math.tan(num);
}

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

private static double zoomAngle(double degrees, int zoom) {
  double theta = Math.toRadians(degrees);
  return 2d * Math.atan(100d * Math.tan(theta / 2d) / zoom);
}

Camera.Parameters p = camera.getParameters();
int zoom = p.getZoomRatios().get(p.getZoom()).intValue();
double thetaH = zoomAngle(p.getHorizontalViewAngle(), zoom);
double thetaV = zoomAngle(p.getVerticalViewAngle(), zoom);

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

public Value tan() throws KettleValueException {
 if ( isNull() ) {
  return this;
 }
 if ( isNumeric() ) {
  setValue( Math.tan( getNumber() ) );
 } else {
  throw new KettleValueException( "Function TAN only works on a number" );
 }
 return this;
}

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

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

代码示例来源:origin: jfoenixadmin/JFoenix

private Point2D makeControlPoint(final double endX, final double endY, final Circle circle, final int numSegments, int direction) {
  final double controlPointDistance = (4.0 / 3.0) * Math.tan(Math.PI / (2 * numSegments)) * circle.getRadius();
  final Point2D center = new Point2D(circle.getCenterX(), circle.getCenterY());
  final Point2D end = new Point2D(endX, endY);
  Point2D perp = rotate(center, end, direction * Math.PI / 2.);
  Point2D diff = perp.subtract(end);
  diff = diff.normalize();
  diff = scale(diff, controlPointDistance);
  return end.add(diff);
}

相关文章