diff options
author | equa <equaa@protonmail.com> | 2021-04-19 20:39:21 -0500 |
---|---|---|
committer | equa <equaa@protonmail.com> | 2021-04-19 20:39:21 -0500 |
commit | 00af64d4e503dd82abf4657ec6fd44b0a418adb2 (patch) | |
tree | 4e864337769f5ddd792db95be3bc761159748af4 /lib/vec.fnl | |
parent | ca870dab91daee38b8d55ac6d2f2b4fd6959c6ac (diff) |
cool bullets
Diffstat (limited to 'lib/vec.fnl')
-rw-r--r-- | lib/vec.fnl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/vec.fnl b/lib/vec.fnl index cce9627..943c7dc 100644 --- a/lib/vec.fnl +++ b/lib/vec.fnl @@ -16,6 +16,9 @@ (fn mag [v] (math.sqrt (+ (* v.x v.x) (* v.y v.y)))) +(fn norm [v n] + (mul v (/ (or n 1) (mag v)))) + (fn wrap [a b] {:x (% a.x b.x) :y (% a.y b.y)}) @@ -24,4 +27,7 @@ {:x (ilerp* a.x b.x c.x d.x x.x) :y (ilerp* a.y b.y c.y d.y x.y)}) -{: lerp : add : sub : mul : mag : wrap} +(fn clone [v] + {:x v.x :y v.y}) + +{: lerp : add : sub : mul : mag : wrap : norm : clone} |