math - Orbit around arbitrary axis glsl -


i animating simple circular orbit around central object using glsl. 2d orbit simple enough, when try object orbiting in other axis becomes more complicated.

float xval = (radius) * sin(timevalue); float yval = (radius) * cos(timevalue); float zval = 0.; 

// n=(nx,ny,nz) rotation axis, if not normalized, use  norm = sqrt(nx*nx+ny*ny+nz*nz) nx /= norm; ny /= norm; nz /= norm  // phi current rotation angle  c=cos(phi); s=sin(phi);  // rotation simple quaternions  q = quaternion(c, s*nx, s*ny, s*nz)  rotated_vec = q.rotate(vec) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -