本文整理汇总了Java中net.jafama.FastMath.atan2方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.atan2方法的具体用法?Java FastMath.atan2怎么用?Java FastMath.atan2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jafama.FastMath
的用法示例。
在下文中一共展示了FastMath.atan2方法的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));
}
示例2: 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;
}
}
示例3: 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;
}
}
示例4: filterRGB
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public int filterRGB(int x, int y, int rgb) {
float dx = x - centreX;
float dy = y - centreY;
float distance = dx * dx + dy * dy;
float angle = (float) FastMath.atan2(dy, dx);
float d = (angle + ImageMath.PI) / (ImageMath.TWO_PI) * rays;
int i = (int) d;
float f = d - i;
if (radius != 0) {
float length = ImageMath.lerp(f, rayLengths[i % rays], rayLengths[(i + 1) % rays]);
float g = length * length / (distance + 0.0001f);
if(amount != 50) { // if amount = 50 then power = 1, but safer to compare ints
g = (float) FastMath.powQuick(g, power);
}
f -= 0.5f;
// f *= amount/50.0f;
f = 1 - f * f;
f *= g;
}
f = ImageMath.clamp(f, 0, 1);
if (lightOnly) {
return ImageMath.mixColors(f, 0, color);
} else {
return ImageMath.mixColors(f, rgb, color);
}
}
示例5: 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 theta = (float) FastMath.atan2(-dy, -dx) + angle;
float r = (float) Math.sqrt(dx * dx + dy * dy);
theta = ImageMath.mod( theta, 2*(float)Math.PI );
out[0] = iWidth * theta/(spreadAngle+0.00001f);
out[1] = iHeight * (1-(r-radius)/(height+0.00001f));
}
示例6: calculateLine
import net.jafama.FastMath; //导入方法依赖的package包/类
private static void calculateLine(int[] destData, int width, int cx, int cy, float hueShift, float saturation, float brightness, int y) {
for (int x = 0; x < width; x++) {
double yDiff = (double) (cy - y);
double xDiff = (double) x - cx;
float angle = (float) (FastMath.atan2(yDiff, xDiff)) + hueShift;
float hue = (float) (angle / (2 * Math.PI));
destData[x + y * width] = Color.HSBtoRGB(hue, saturation, brightness);
}
}
示例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;
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);
}
}
示例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);
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);
}
示例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);
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);
}
示例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);
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);
}
示例11: 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);
}
示例12: mousePressed
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
// Start drag.
startcamera = new Simple1DOFCamera(camera);
Point startPoint = e.getPoint();
mapMouseToPlane(startcamera, startPoint, startvec);
startangle = FastMath.atan2(startvec[1], startvec[0]);
}
示例13: mouseDragged
import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
mapMouseToPlane(startcamera, e.getPoint(), endvec);
double upangle = FastMath.atan2(endvec[1], endvec[0]);
camera.setRotationZ(startcamera.getRotationZ() + (upangle - startangle));
// TODO: add full arcball support?
}
示例14: 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 theta = FastMath.atan2(dy, dx) + Math.PI;
double rd = 0.45 * Math.min(srcWidth, srcHeight);
// System.out.println(String.format("Sphere3DFilter::transformInverse: r = %.2f, rd = %.2f", r, rd));
if (r > rd) {
out[0] = -1;
out[1] = -1;
return;
}
double sa = FastMath.sin(alpha);
double sb = FastMath.sin(beta);
double ca = FastMath.cos(alpha);
double cb = FastMath.cos(beta);
double phi = FastMath.acos(r / rd);
double x0 = FastMath.cos(theta) * FastMath.cos(phi);
double y0 = FastMath.sin(theta) * FastMath.cos(phi);
double z0 = FastMath.sin(phi);
double x1 = ca * x0 + sa * y0;
double z1 = -sa * -sb * x0 + ca * -sb * y0 + cb * z0;
double y1 = cb * -sa * x0 + cb * ca * y0 + sb * z0;
// double theta1 = Math.atan(-x1 / y1) + (y1 > 0 ? Math.PI / 2 : 3 * Math.PI / 2);
double theta1 = FastMath.atan(-x1 / y1);
double phi1 = FastMath.asin(z1);
int X = srcWidth / 2;
int Y = srcHeight / 2;
// out[0] = Math.abs((float) (((theta1 * 2 + gamma) % (2 * Math.PI) - Math.PI) / Math.PI * X));
// out[1] = Math.abs((float) (-phi1 / (Math.PI / 2) * Y));
out[0] = (float) ((((((theta1 * 2) + gamma) % (2 * Math.PI)) - Math.PI) / Math.PI) * X);
out[1] = (float) (-phi1 / (Math.PI / 2) * Y);
// System.out.println(String.format("Sphere3DFilter::transformInverse: out[0] = %.2f, out[1] = %.2f", out[0], out[1]));
}
示例15: 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);
return FastMath.atan2(z, p);
}