summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-07-15 22:36:27 -0400
committerDavid Thompson <dthompson2@worcester.edu>2013-07-15 22:36:27 -0400
commit0525bcc690cafa10a30e3cf2490e52695a8f7309 (patch)
treef8cbc4c5295221a51fcd80e0504e04d6a6d00d55 /2d
parent7236dca74c9f7b832b21d2cbfa0106952f855977 (diff)
Add vector-from-polar procedure.
Diffstat (limited to '2d')
-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))))