当前位置: 首页>>代码示例>>Java>>正文


Java FastMath.sinAndCos方法代码示例

本文整理汇总了Java中net.jafama.FastMath.sinAndCos方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.sinAndCos方法的具体用法?Java FastMath.sinAndCos怎么用?Java FastMath.sinAndCos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.jafama.FastMath的用法示例。


在下文中一共展示了FastMath.sinAndCos方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: latLngRadToECEF

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public double[] latLngRadToECEF(double lat, double lng) {
  // Then to sine and cosines:
  final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
  final double slat = FastMath.sinAndCos(lat, tmp), clat = tmp.value;
  final double slng = FastMath.sinAndCos(lng, tmp), clng = tmp.value;

  return new double[] { EARTH_RADIUS * clat * clng, EARTH_RADIUS * clat * slng, EARTH_RADIUS * slat };
}
 
开发者ID:elki-project,项目名称:elki,代码行数:10,代码来源:SphericalCosineEarthModel.java

示例2: latLngRadToECEF

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public double[] latLngRadToECEF(double lat, double lng) {
  // Sine and cosines:
  final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
  final double slat = FastMath.sinAndCos(lat, tmp), clat = tmp.value;
  final double slng = FastMath.sinAndCos(lng, tmp), clng = tmp.value;

  final double v = a / FastMath.sqrt(1 - esq * slat * slat);
  return new double[] { v * clat * clng, v * clat * slng, (1 - esq) * v * slat };
}
 
开发者ID:elki-project,项目名称:elki,代码行数:11,代码来源:AbstractEarthModel.java

示例3: svgCircleSegment

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Create a circle segment.
 *
 * @param svgp Plot to draw to
 * @param centerx Center X position
 * @param centery Center Y position
 * @param angleStart Starting angle
 * @param angleDelta Angle delta
 * @param innerRadius inner radius
 * @param outerRadius outer radius
 * @return SVG element representing this circle segment
 */
public static Element svgCircleSegment(SVGPlot svgp, double centerx, double centery, double angleStart, double angleDelta, double innerRadius, double outerRadius) {
  final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
  double sin1st = FastMath.sinAndCos(angleStart, tmp);
  double cos1st = tmp.value;

  double sin2nd = FastMath.sinAndCos(angleStart + angleDelta, tmp);
  double cos2nd = tmp.value;

  double inner1stx = centerx + (innerRadius * sin1st);
  double inner1sty = centery - (innerRadius * cos1st);
  double outer1stx = centerx + (outerRadius * sin1st);
  double outer1sty = centery - (outerRadius * cos1st);

  double inner2ndx = centerx + (innerRadius * sin2nd);
  double inner2ndy = centery - (innerRadius * cos2nd);
  double outer2ndx = centerx + (outerRadius * sin2nd);
  double outer2ndy = centery - (outerRadius * cos2nd);

  double largeArc = 0;
  if(angleDelta >= Math.PI) {
    largeArc = 1;
  }

  SVGPath path = new SVGPath(inner1stx, inner1sty);
  path.lineTo(outer1stx, outer1sty);
  path.ellipticalArc(outerRadius, outerRadius, 0, largeArc, 1, outer2ndx, outer2ndy);
  path.lineTo(inner2ndx, inner2ndy);
  if(innerRadius > 0) {
    path.ellipticalArc(innerRadius, innerRadius, 0, largeArc, 0, inner1stx, inner1sty);
  }

  return path.makeElement(svgp);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:46,代码来源:SVGUtil.java

示例4: FullTable

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Constructor for tables with
 * 
 * @param steps
 */
public FullTable(int steps) {
  super(steps);
  final double radstep = Math.toRadians(360. / steps);
  this.costable = new double[steps];
  this.sintable = new double[steps];
  double ang = 0.;
  final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
  for (int i = 0; i < steps; i++, ang += radstep) {
    this.sintable[i] = FastMath.sinAndCos(ang, tmp);
    this.costable[i] = tmp.value;
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:18,代码来源:SinCosTable.java

示例5: addRotation

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Convenience function to apply a rotation in 2 dimensions.
 *
 * @param axis1 first dimension
 * @param axis2 second dimension
 * @param angle rotation angle in radians.
 */
public void addRotation(int axis1, int axis2, double angle) {
  // TODO: throw an exception instead of using assert
  assert (axis1 >= 0);
  assert (axis1 < dim);
  assert (axis1 >= 0);
  assert (axis2 < dim);
  assert (axis1 != axis2);

  // reset inverse transformation - needs recomputation.
  inv = null;

  double[][] ht = new double[dim + 1][dim + 1];
  // identity matrix
  for(int i = 0; i < dim + 1; i++) {
    ht[i][i] = 1.0;
  }
  // insert rotation values
  final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
  double s = FastMath.sinAndCos(angle, tmp), c = tmp.value;
  ht[axis1][axis1] = +c;
  ht[axis1][axis2] = -s;
  ht[axis2][axis1] = +s;
  ht[axis2][axis2] = +c;
  // Multiply from left
  trans = times(ht, trans);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:34,代码来源:AffineTransformation.java

示例6: computeWeightMatrix

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Compute the weight matrix for HSB similarity.
 *
 * @param quanth H bins
 * @param quants S bins
 * @param quantb B bins
 * @return Weight matrix
 */
public static double[][] computeWeightMatrix(final int quanth, final int quants, final int quantb) {
  final int dim = quanth * quants * quantb;
  final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
  assert (dim > 0);
  final double[][] m = new double[dim][dim];
  for(int x = 0; x < dim; x++) {
    final int hx = x / (quantb * quants);
    final int sx = (x / quantb) % quants;
    final int bx = x % quantb;
    for(int y = x; y < dim; y++) {
      final int hy = y / (quantb * quants);
      final int sy = (y / quantb) % quants;
      final int by = y % quantb;

      final double shx = FastMath.sinAndCos((hx + .5) / quanth * MathUtil.TWOPI, tmp);
      final double chx = tmp.value;
      final double shy = FastMath.sinAndCos((hy + .5) / quanth * MathUtil.TWOPI, tmp);
      final double chy = tmp.value;
      final double cos = chx * (sx + .5) / quants - chy * (sy + .5) / quants;
      final double sin = shx * (sx + .5) / quants - shy * (sy + .5) / quants;
      final double db = (bx - by) / (double) quantb;
      final double val = 1. - FastMath.sqrt((db * db + sin * sin + cos * cos) / 5);
      m[x][y] = m[y][x] = val;
    }
  }
  return m;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:36,代码来源:HSBHistogramQuadraticDistanceFunction.java

示例7: drawCosine

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Visualizes Cosine and ArcCosine distance functions
 *
 * @param svgp SVG Plot
 * @param proj Visualization projection
 * @param mid mean vector
 * @param angle Opening angle in radians
 * @return path element
 */
public static Element drawCosine(SVGPlot svgp, Projection2D proj, NumberVector mid, double angle) {
  // Project origin
  double[] pointOfOrigin = proj.fastProjectDataToRenderSpace(new double[proj.getInputDimensionality()]);

  // direction of the selected Point
  double[] selPoint = proj.fastProjectDataToRenderSpace(mid);

  double[] range1, range2;
  {
    // Rotation plane:
    double[] p1 = proj.fastProjectRenderToDataSpace(selPoint[0] + 10, selPoint[1]);
    double[] p2 = proj.fastProjectRenderToDataSpace(selPoint[0], selPoint[1] + 10);
    double[] pm = mid.toArray();
    // Compute relative vectors
    minusEquals(p1, pm);
    minusEquals(p2, pm);
    // Scale p1 and p2 to unit length:
    timesEquals(p1, 1. / euclideanLength(p1));
    timesEquals(p2, 1. / euclideanLength(p2));
    {
      double test = scalarProduct(p1, p2);
      if(Math.abs(test) > 1E-10) {
        LoggingUtil.warning("Projection does not seem to be orthogonal?");
      }
    }
    // Project onto p1, p2:
    double l1 = scalarProduct(pm, p1), l2 = scalarProduct(pm, p2);
    // Rotate projection by + and - angle
    // Using sin(-x) = -sin(x) and cos(-x)=cos(x)
    final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
    final double sangle = FastMath.sinAndCos(angle, tmp), cangle = tmp.value;
    double r11 = +cangle * l1 - sangle * l2, r12 = +sangle * l1 + cangle * l2;
    double r21 = +cangle * l1 + sangle * l2, r22 = -sangle * l1 + cangle * l2;
    // Build rotated vectors - remove projected component, add rotated
    // component:
    double[] r1 = copy(pm), r2 = copy(pm);
    plusTimesEquals(r1, p1, -l1 + r11);
    plusTimesEquals(r1, p2, -l2 + r12);
    plusTimesEquals(r2, p1, -l1 + r21);
    plusTimesEquals(r2, p2, -l2 + r22);
    // Project to render space:
    range1 = proj.fastProjectDataToRenderSpace(r1);
    range2 = proj.fastProjectDataToRenderSpace(r2);
  }

  // Continue lines to viewport.
  {
    CanvasSize viewport = proj.estimateViewport();
    minusEquals(range1, pointOfOrigin);
    minusEquals(range2, pointOfOrigin);
    timesEquals(range1, viewport.continueToMargin(pointOfOrigin, range1));
    timesEquals(range2, viewport.continueToMargin(pointOfOrigin, range2));
    plusEquals(range1, pointOfOrigin);
    plusEquals(range2, pointOfOrigin);
    // Go backwards into the other direction - the origin might not be in the
    // viewport!
    double[] start1 = minus(pointOfOrigin, range1);
    double[] start2 = minus(pointOfOrigin, range2);
    timesEquals(start1, viewport.continueToMargin(range1, start1));
    timesEquals(start2, viewport.continueToMargin(range2, start2));
    plusEquals(start1, range1);
    plusEquals(start2, range2);

    // TODO: add filled variant?
    SVGPath path = new SVGPath();
    path.moveTo(start1);
    path.lineTo(range1);
    path.moveTo(start2);
    path.lineTo(range2);
    return path.makeElement(svgp);
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:82,代码来源:DistanceFunctionVisualization.java


注:本文中的net.jafama.FastMath.sinAndCos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。