;http://en.wikipedia.org/wiki/Atan2
(define (atan2 x y)
(* 2 (atan (/ (- (sqrt (+ (expt x 2)
(expt y 2)))
x)
y))))
;Orig is a position (vector), speed is a number. Function returns the speedvec required to move to this direction
(define (vectorToAngles orig speed)
(let* ((to_x (orig 'getX))
(to_y (orig 'getY))
(from_x (getX vector))
(from_y (getY vector)))
(println "from = " vector " -- to = " orig)
(define angle (atan2 (- to_x from_y) (- to_x from_y)))
(((makeVector (cos angle) (sin angle)) 'vec*) speed)))