opengl:rotate any angle

废话不多说了,直接贴代码
/**
* // camera target:We are looking toward the distance
* @param tx, the camera target x
* @param ty, the camera target y
* @param tz, the camera target z
* // Set our up vector. This is where our head would be pointing were we holding the camera.for example, (0,1,0),we'll toward the up position to rotate
* @param upX
* @param upY
* @param upZ
* @param angle
* @return
*/
private float[] roateAnyAngle(float tx, float ty, float tz, float upX, float upY, float upZ, float angle){
float[] nt = new float[3];
double x = tx;
double y = ty;
double z = tz;
double u = upX;
double v = upY;
double w = upZ;

double ux = u * x;
double uy = u * y;
double uz = u * z;
double vx = v * x;
double vy = v * y;
double vz = v * z;
double wx = w * x;
double wy = w * y;
double wz = w * z;
double sa = Math.sin(angle);
double ca = Math.cos(angle);
nt[0] = (float) (u * (ux + vy + wz)
+ (x * (v * v + w * w) - u * (vy + wz)) * ca + (-wy + vz) * sa);
nt[1] = (float) (v * (ux + vy + wz)
+ (y * (u * u + w * w) - v * (ux + wz)) * ca + (wx - uz) * sa);
nt[2] = (float) (w * (ux + vy + wz)
+ (z * (u * u + v * v) - w * (ux + vy)) * ca + (-vx + uy) * sa);
return nt;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值