mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-11-10 08:05:56 +00:00
moved trig functions from shell into phys namespace
This commit is contained in:
parent
1a5b3e3727
commit
faee52fcd8
@ -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]
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user