我使用GLSL为中心对象周围的简单圆形轨道制作动画。 2d轨道很简单,但是当我试图让物体绕其他轴旋转时,它变得更加复杂。
float xVal = (radius) * sin(timeValue);
float yVal = (radius) * cos(timeValue);
float zVal = 0.;
答案 0 :(得分:0)
// n=(nx,ny,nz) is the rotation axis, if not normalized, use
norm = sqrt(nx*nx+ny*ny+nz*nz)
nx /= norm; ny /= norm; nz /= norm
// phi is the current rotation angle
c=cos(phi); s=sin(phi);
// rotation is most simple with quaternions
q = quaternion(c, s*nx, s*ny, s*nz)
rotated_vec = q.rotate(vec)