java fast math,Java FastMath.asin方法代碼示例

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]));

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值