Rotate one vector around another a certain angle

From Director Online Wiki
Jump to: navigation, search

Copy and paste on a movie script:


  -----------------------------------------
  on rotateVector (v, u, alfa)
  -- rotates vector v around u alfa degrees
  -- returns rotated vector
  -- by Iñigo de Gracia
  -----------------------------------------
  u.normalize()
  alfa = alfa*pi()/180 -- alfa in rads
  uv = u.cross(v)
  vect = v + sin (alfa) * uv + 2*power(sin(alfa/2), 2) * (u.cross(uv))
  return vect
end