summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-08-28 14:48:27 -0400
committerDavid Thompson <dthompson2@worcester.edu>2020-10-13 08:47:59 -0400
commit6aa56d454814acbdbc495798d0658392128f8f53 (patch)
tree3e7cb4122e1040216c10d600cf7a6d71202913eb
parent69413418072d45ccdb1bc1d682fbf18913bd291a (diff)
math: vector: Add origin argument to vec2/polar.
-rw-r--r--chickadee/math/vector.scm7
1 files 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."