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


Java FastMath.cos方法代码示例

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


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

示例1: transformInverse

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
  protected void transformInverse(int x, int y, float[] out) {
      double dx = x - icentreX;
      double dy = y - icentreY;
      double r = Math.sqrt(dx * dx + dy * dy);
      double theta = FastMath.atan2(dy, dx) - angle - angle2;
      theta = ImageMath.triangle((float) (theta / Math.PI * sides * .5));
      if (radius != 0) {
          double c = FastMath.cos(theta);
          double radiusc = radius / c;
          r = radiusc * ImageMath.triangle( (float)(r/radiusc) );
}
theta += angle;

      double zoomedR = r / zoom;
      out[0] = (float)(icentreX + zoomedR*FastMath.cos(theta));
      out[1] = (float)(icentreY + zoomedR*FastMath.sin(theta));
  }
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:19,代码来源:KaleidoscopeFilter.java

示例2: ecefToLatLngRadHeight

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public double[] ecefToLatLngRadHeight(double x, double y, double z) {
  double lng = FastMath.atan2(y, x);
  final double p = FastMath.sqrt(x * x + y * y);
  double plat = FastMath.atan2(z, p * (1 - esq));
  double h = 0;

  // Iteratively improving the lat value
  // TODO: instead of a fixed number of iterations, check for convergence?
  for (int i = 0;; i++) {
    final double slat = FastMath.sin(plat);
    final double v = a / FastMath.sqrt(1 - esq * slat * slat);
    double lat = FastMath.atan2(z + esq * v * slat, p);
    if (Math.abs(lat - plat) < PRECISION || i > MAX_ITER) {
      h = p / FastMath.cos(lat) - v;
      return new double[] { lat, lng, h };
    }
    plat = lat;
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:21,代码来源:AbstractEarthModel.java

示例3: extremum_alpha_n

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Determines the value for alpha_n where this function has a (local)
 * extremum.
 * 
 * @param n the index of the angle
 * @param alpha the already determined alpha_values for the extremum
 * @return the value for alpha_n where this function has a (local) extremum
 */
private double extremum_alpha_n(int n, double[] alpha) {
  // arctan(infinity) = PI/2
  if(vec.doubleValue(n) == 0) {
    return MathUtil.HALFPI;
  }

  double tan = 0;
  for(int j = n + 1; j < vec.getDimensionality(); j++) {
    double alpha_j = j == vec.getDimensionality() - 1 ? 0 : alpha[j];
    tan += vec.doubleValue(j) * sinusProduct(n + 1, j, alpha) * FastMath.cos(alpha_j);
  }
  tan /= vec.doubleValue(n);

  // if (debug) {
  // debugFiner("tan alpha_" + (n + 1) + " = " + tan);
  // }
  double alpha_n = Math.atan(tan);
  if(alpha_n < 0) {
    alpha_n = Math.PI + alpha_n;
  }
  return alpha_n;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:31,代码来源:ParameterizationFunction.java

示例4: main

import net.jafama.FastMath; //导入方法依赖的package包/类
public static void main(String[] args) {
    // allows to put the app into development mode by
    // adding -Dpixelitor.development=true to the command line
    if ("true".equals(System.getProperty("pixelitor.development"))) {
        Utils.checkThatAssertionsAreEnabled();
        Build.CURRENT = Build.DEVELOPMENT;
    }

    setupForMacintosh();

    ExceptionHandler.INSTANCE.register();
    EventQueue.invokeLater(() -> {
        try {
            for(String arg : args){
                System.out.println(arg+"--");
            }
            System.out.println(args);
            createAndShowGUI(args);

            // this will run on a different thread, but call it
            // here because it is IO-intensive and it should not
            // slow down the loading of the GUI
            preloadFontNames();
        } catch (Exception e) {
            Dialogs.showExceptionDialog(e);
        }
    });

    // Force the initialization of FastMath look-up tables now
    // so that later no unexpected delays happen.
    // This is OK because static initializers are thread safe.
    FastMath.cos(0.1);
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:34,代码来源:Pixelitor.java

示例5: RandomStar

import net.jafama.FastMath; //导入方法依赖的package包/类
public RandomStar(double x, double y, int width, int height) {
    double centerX = x + width / 2.0;
    double centerY = y + height / 2.0;
    int[] radii = new int[numRadius];
    int maxRadius = 1 + width / 2;

    radii[0] = maxRadius;
    for (int i = 1; i < radii.length; i++) {
        radii[i] = (int) (maxRadius * radiusRatios[i]);
    }
    double heightToWidthRatio = height / (double)width;

    for (int i = 0; i < numPoints; i++) {
        double angle = initialAngle + i * unitAngle;
        int radiusIndex = i % radii.length;
        int radius = radii[radiusIndex];
        double circleX = FastMath.cos(angle) * radius;
        double circleY = FastMath.sin(angle) * radius;
        double relX = centerX + circleX;
        double relY = centerY + heightToWidthRatio * circleY;

        if(delegate == null) {
            delegate = new GeneralPath();
            delegate.moveTo(relX, relY);
        } else {
            delegate.lineTo(relX, relY);
        }
    }
    delegate.closePath();

}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:32,代码来源:RandomStar.java

示例6: transformInverse

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
    float dx = x - cx;
    float dy = y - cy;
    float xDist = Math.abs(dx);

    float yDist = Math.abs(dy);
    if ((xDist > radiusX) || (yDist > radiusY)) { // out of the affected area
        out[0] = x;
        out[1] = y;
        return;
    }

    double angle;
    if (xDist >= yDist) { // we want to move from a vertical line  to the circle
        angle = FastMath.atan2(dy, xDist);
    } else { // move from horizontal line
        angle = FastMath.atan2(dx, yDist);
    }

    double magnificationInverse = FastMath.cos(angle);

    // dividing by radiusRatio transforms the circle-to-square transformation
    // into an ellipse-to-rectangle transformation
    float transformedX = cx + (float) (dx * magnificationInverse / radiusRatio);
    float transformedY = cy + (float) (dy * magnificationInverse);

    if (amount == 1.0f) {
        out[0] = transformedX;
        out[1] = transformedY;
    } else {
        out[0] = x + amount * (transformedX - x);
        out[1] = y + amount * (transformedY - y);
    }
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:36,代码来源:CircleToSquareFilter.java

示例7: transformInverse

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
    protected void transformInverse(int x, int y, float[] out) {
        float dx = x - cx;
        float dy = y - cy;
        double r = Math.sqrt(dx * dx + dy * dy);
        double angle = FastMath.atan2(dy, dx);

        float randomShift = 0;
        if (randomness > 0) {
//            randomShift = randomness * Noise.noise2((float) angle, (float) (2.0f * r / srcWidth));
            randomShift = randomness * Noise.noise2(dx / srcWidth, dy / srcHeight);
        }

        if (numADivisions > 0) {
            double angleShift = FastMath.tan(randomShift + t + angle * numADivisions / 2) * curvature * (numADivisions / 4.0) / r;
            angle += angleShift;
        }

        if (numRDivisions > 0) {
            double rShift = FastMath.tan(3 * randomShift + r / srcWidth * 2 * Math.PI * numRDivisions) * numRDivisions * curvature / 2;
            r += rShift;
        }

        angle += rotateResult;

        double zoomedR = r / zoom;
        float u = (float) (zoomedR * FastMath.cos(angle));
        float v = (float) (zoomedR * FastMath.sin(angle));

        out[0] = (u + cx);
        out[1] = (v + cy);
    }
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:33,代码来源:PolarTilesFilter.java

示例8: transformInverse

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
    float dx = x - cx;
    float dy = y - cy;
    double r = Math.sqrt(dx * dx + dy * dy);
    double angle = FastMath.atan2(dy, dx);

    double na = r / radialWL - phase;
    double fa;

    switch (waveType) {
        case WaveType.SINE:
            fa = FastMath.sin(na);
            break;
        case WaveType.SAWTOOTH:
            fa = ImageMath.sinLikeSawtooth(na);
            break;
        case WaveType.TRIANGLE:
            fa = ImageMath.sinLikeTriangle(na);
            break;
        case WaveType.NOISE:
            fa = Noise.sinLikeNoise1((float)na);
            break;
        default:
            throw new IllegalStateException("waveType = " + waveType);
    }

    angle += fa * amount;

    double zoomedR = r / zoom;
    float u = (float) (zoomedR * FastMath.cos(angle));
    float v = (float) (zoomedR * FastMath.sin(angle));

    out[0] = (u + cx);
    out[1] = (v + cy);
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:37,代码来源:AngularWavesFilter.java

示例9: transformInverse

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
    float dx = x - cx;
    float dy = y - cy;
    double r = Math.sqrt(dx * dx + dy * dy);
    double angle = FastMath.atan2(dy, dx);
    angle += rotateResult;

    double zoomedR = r / zoom;
    float u = (float) (zoomedR * FastMath.cos(angle));
    float v = (float) (zoomedR * FastMath.sin(angle));

    out[0] = (u + cx);
    out[1] = (v + cy);
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:16,代码来源:EmptyPolarFilter.java

示例10: transformInverse

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
    protected void transformInverse(int x, int y, float[] out) {
        float dx = x - cx;
        float dy = y - cy;
        double r = Math.sqrt(dx * dx + dy * dy);
        double angle = FastMath.atan2(dy, dx);

//        double angularWL = 1.0 / angularDivision;
        double nr = angle * angularDivision - phase;
        double fr;

        switch (waveType) {
            case WaveType.SINE:
                fr = FastMath.sin(nr);
                break;
            case WaveType.SAWTOOTH:
                fr = ImageMath.sinLikeSawtooth(nr);
                break;
            case WaveType.TRIANGLE:
                fr = ImageMath.sinLikeTriangle(nr);
                break;
            case WaveType.NOISE:
                fr = Noise.sinLikeNoise1((float)nr);
                break;
            default:
                throw new IllegalStateException("waveType = " + waveType);
        }

        r += fr * radialAmplitude * r / maxSize;

        double zoomedR = r / zoom;
        float u = (float) (zoomedR * FastMath.cos(angle));
        float v = (float) (zoomedR * FastMath.sin(angle));

        out[0] = (u + cx);
        out[1] = (v + cy);
    }
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:38,代码来源:RadialWavesFilter.java

示例11: getRangeForObject

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public void getRangeForObject(V obj, double range, ModifiableDoubleDBIDList result) {
  HashSetModifiableDBIDs cands = DBIDUtil.newHashSet();
  WritableDoubleDataStore scores = DataStoreUtil.makeDoubleStorage(cands, //
      DataStoreFactory.HINT_TEMP | DataStoreFactory.HINT_HOT, 0.);
  double len = naiveQuery(obj, scores, cands);
  // dist = acos(sim/len) <-> sim = cos(dist)*len
  double simrange = FastMath.cos(range) * len;
  for(DBIDIter n = cands.iter(); n.valid(); n.advance()) {
    double sim = scores.doubleValue(n) / length.doubleValue(n);
    if(sim >= simrange) {
      result.add(Math.acos(sim / len), n);
    }
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:16,代码来源:InMemoryInvertedIndex.java

示例12: setRotationZ

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Set the z rotation angle in radians.
 * 
 * @param rotationZ Z rotation angle.
 */
public void setRotationZ(double rotationZ) {
  this.rotationZ = rotationZ;
  this.cosZ = FastMath.cos(rotationZ);
  this.sinZ = FastMath.sin(rotationZ);

  fireCameraChangedEvent();
}
 
开发者ID:elki-project,项目名称:elki,代码行数:13,代码来源:Simple1DOFCamera.java

示例13: computePositions

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Compute the layout positions
 * 
 * @param node Node to start with
 * @param depth Depth of the node
 * @param aoff Angular offset
 * @param awid Angular width
 * @param maxdepth Maximum depth (used for radius computations)
 */
public static void computePositions(Node node, int depth, double aoff, double awid, int maxdepth) {
  double r = depth / (maxdepth - 1.);
  node.x = FastMath.sin(aoff + awid * .5) * r;
  node.y = FastMath.cos(aoff + awid * .5) * r;

  double cpos = aoff;
  double cwid = awid / node.weight;
  for (Node c : node.children) {
    computePositions(c, depth + 1, cpos, cwid * c.weight, maxdepth);
    cpos += cwid * c.weight;
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:22,代码来源:SimpleCircularMSTLayout3DPC.java

示例14: function

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Computes the function value at <code>alpha</code>.
 * 
 * @param alpha the values of the d-1 angles
 * @return the function value at alpha
 */
public double function(double[] alpha) {
  final int d = vec.getDimensionality();
  if(alpha.length != d - 1) {
    throw new IllegalArgumentException("Parameter alpha must have a " + "dimensionality of " + (d - 1) + ", read: " + alpha.length);
  }

  double result = 0;
  for(int i = 0; i < d; i++) {
    double alpha_i = i == d - 1 ? 0 : alpha[i];
    result += vec.doubleValue(i) * sinusProduct(0, i, alpha) * FastMath.cos(alpha_i);
  }
  return result;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:20,代码来源:ParameterizationFunction.java

示例15: HalfTable

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


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