moved trig functions from shell into phys namespace

This commit is contained in:
Richard Harrington 2013-08-21 13:19:21 -04:00
parent 1a5b3e3727
commit faee52fcd8
2 changed files with 15 additions and 12 deletions

View File

@ -1,6 +1,17 @@
(ns robotwar.phys)
; yay classical mechanics
; trig functions
(defn deg->rad
[angle]
(* angle (/ Math/PI 180)))
(defn decompose-angle
[angle]
{:x (Math/cos angle)
:y (Math/sin angle)})
; classical mechanics functions
(defn time-to-reach-desired-v
[vi vf a]

View File

@ -1,20 +1,12 @@
(ns robotwar.shell
(:use [robotwar.constants]))
(defn deg->rad
[angle]
(* angle (/ Math/PI 180)))
(defn decompose-angle
[angle]
{:x (Math/cos angle)
:y (Math/sin angle)})
(:use [robotwar.constants])
(:require [robotwar.phys :as phys]))
(defn init-shell
[pos-x pos-y aim distance]
; TODO: make the starting point dependent upon the robot radius,
; which should be in constants.
(let [{unit-x :x unit-y :y} (decompose-angle (deg->rad aim))]
(let [{unit-x :x unit-y :y} (phys/decompose-angle (phys/deg->rad aim))]
{:pos-x pos-x
:pos-y pos-y
:v-x (* unit-x SHELL-SPEED)