diff options
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} |