From 6aa56d454814acbdbc495798d0658392128f8f53 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 28 Aug 2020 14:48:27 -0400 Subject: math: vector: Add origin argument to vec2/polar. --- chickadee/math/vector.scm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/chickadee/math/vector.scm b/chickadee/math/vector.scm index 4206206..e2720c6 100644 --- a/chickadee/math/vector.scm +++ b/chickadee/math/vector.scm @@ -142,10 +142,11 @@ (vec3-set! v 1 y) (vec3-set! v 2 z))) -(define-inlinable (vec2/polar r theta) +(define-inlinable (vec2/polar origin r theta) "Return a new vec2 containing the Cartesian representation of the -polar coordinate (R, THETA)." - (vec2 (* r (cos theta)) (* r (sin theta)))) +polar coordinate (R, THETA) with an arbitrary ORIGIN point." + (vec2 (+ (vec2-x origin) (* r (cos theta))) + (+ (vec2-y origin) (* r (sin theta))))) (define-inlinable (vec2-x v) "Return the x coordinate of the vec2 V." -- cgit v1.2.3