本文整理汇总了Java中net.jafama.FastMath.sin方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.sin方法的具体用法?Java FastMath.sin怎么用?Java FastMath.sin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jafama.FastMath
的用法示例。
在下文中一共展示了FastMath.sin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformInverse
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
float dx = x - icentreX;
float dy = y - icentreY;
float distance2 = dx * dx + dy * dy;
if (distance2 > radius2) {
out[0] = x;
out[1] = y;
} else {
float distance = (float) Math.sqrt(distance2);
float amount = amplitude * (float) FastMath.sin(distance / wavelength * ImageMath.TWO_PI - phase);
amount *= (radius-distance)/radius;
if ( distance != 0 ) {
amount *= wavelength / distance;
}
out[0] = x + dx*amount;
out[1] = y + dy*amount;
}
}
示例2: 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));
}
示例3: ecefToLatRad
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public double ecefToLatRad(double x, double y, double z) {
final double p = FastMath.sqrt(x * x + y * y);
double plat = FastMath.atan2(z, p * (1 - esq));
// 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);
final double lat = FastMath.atan2(z + esq * v * slat, p);
if (Math.abs(lat - plat) < PRECISION || i > MAX_ITER) {
return lat;
}
plat = lat;
}
}
示例4: 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;
}
}
示例5: transformInverse
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
protected void transformInverse(int x, int y, float[] out) {
float nx = (float) y / xWavelength;
float ny = (float) x / yWavelength;
float fx, fy;
switch (waveType) {
case WaveType.SINE:
default:
fx = (float) FastMath.sin(nx - phaseY);
fy = (float) FastMath.sin(ny - phaseX);
break;
case WaveType.SAWTOOTH:
fx = ImageMath.sinLikeSawtooth(nx - phaseY);
fy = ImageMath.sinLikeSawtooth(ny - phaseX);
break;
case WaveType.TRIANGLE:
fx = ImageMath.sinLikeTriangle(nx - phaseY);
fy = ImageMath.sinLikeTriangle(ny - phaseX);
break;
case WaveType.NOISE:
fx = Noise.sinLikeNoise1(nx - phaseY);
fy = Noise.sinLikeNoise1(ny - phaseX);
break;
}
out[0] = x + xAmplitude * fx;
out[1] = y + yAmplitude * fy;
}
示例6: 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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例11: 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();
}
示例12: 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;
}
}
示例13: 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);
}
}
示例14: estimateFromLMoments
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public GeneralizedLogisticAlternateDistribution estimateFromLMoments(double[] xmom) {
double shape = -xmom[2];
if(!(shape >= -1 && shape <= 1)) {
throw new ArithmeticException("Invalid moment estimation.");
}
if(Math.abs(shape) < 1e-6) {
// Effectively zero, so non-generalized.
return new GeneralizedLogisticAlternateDistribution(xmom[0], xmom[1], 0.);
}
double tmp = shape * Math.PI / FastMath.sin(shape * Math.PI);
double scale = xmom[1] / tmp;
double location = xmom[0] - scale * (1. - tmp) / shape;
return new GeneralizedLogisticAlternateDistribution(location, scale, shape);
}
示例15: filter
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public BufferedImage filter( BufferedImage src, BufferedImage dst ) {
int width = src.getWidth();
int height = src.getHeight();
if ( dst == null ) {
dst = createCompatibleDestImage(src, null);
}
int[] inPixels = new int[width];
int[] outPixels = new int[width];
int a = color & 0xff000000;
int r = (color >> 16) & 0xff;
int g = (color >> 8) & 0xff;
int b = color & 0xff;
for ( int y = 0; y < height; y++ ) {
for ( int x = 0; x < width; x++ ) {
int tr = r;
int tg = g;
int tb = b;
if ( shine != 0 ) {
int f = (int)(255*shine* FastMath.sin((double) x / width * Math.PI));
tr += f;
tg += f;
tb += f;
}
if (monochrome) {
int n = (int)(255 * (2*random.nextFloat() - 1) * amount);
inPixels[x] = a | (clamp(tr+n) << 16) | (clamp(tg+n) << 8) | clamp(tb+n);
} else {
inPixels[x] = a | (random(tr) << 16) | (random(tg) << 8) | random(tb);
}
}
if ( radius != 0 ) {
blur( inPixels, outPixels, width, radius );
AbstractBufferedImageOp.setRGB( dst, 0, y, width, 1, outPixels );
} else {
AbstractBufferedImageOp.setRGB(dst, 0, y, width, 1, inPixels);
}
}
return dst;
}