summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2d/vector.scm7
1 files changed, 6 insertions, 1 deletions
diff --git a/2d/vector.scm b/2d/vector.scm
index 7dcbcb2..bd14dd5 100644
--- a/2d/vector.scm
+++ b/2d/vector.scm
@@ -31,7 +31,8 @@
scale
mag
normalize
- vector-reduce))
+ vector-reduce
+ vector-from-polar))
(define (vx vector)
"Returns the first element of a vector."
@@ -79,3 +80,7 @@
(if (= (vector-length vector) i)
prev
(loop (1+ i) (proc prev (vector-ref vector i))))))))
+
+(define (vector-from-polar r theta)
+ (vector (* r (cos theta))
+ (* r (sin theta))))