Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 16e859b62d
Fetching contributors…

Cannot retrieve contributors at this time

16 lines (12 sloc) 0.463 kb
(ns coloured-balls.motion
(:use [clojure.contrib.generic.math-functions :only (round, cos, sin)]))
(defn degrees-to-radians [degrees]
(* (/ Math/PI 180) degrees))
(defn move [item]
(let [heading (degrees-to-radians (:heading item))
velocity (:velocity item)
old-x (:x item)
old-y (:y item)
new-x (round (* velocity (cos heading)))
new-y (round (* velocity (sin heading)))]
(conj {:x (+ old-x new-x) :y (+ old-y new-y)} (dissoc item :x :y))))
Jump to Line
Something went wrong with that request. Please try again.