summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dave@izanagi>2013-06-23 11:33:29 -0400
committerDavid Thompson <dave@izanagi>2013-06-23 11:33:29 -0400
commit79d2a157e827c587dc3a9774f7e552690821e797 (patch)
treea5f5051dcb8eb1af4719259b990c807ebe820f31 /2d
parente8be6c28ff61e1febf3a7c2d21ffacd772c487c9 (diff)
Add vx, vy, and vz convenience procedures.
Diffstat (limited to '2d')
-rw-r--r--2d/vector.scm17
1 files changed, 16 insertions, 1 deletions
diff --git a/2d/vector.scm b/2d/vector.scm
index 9dc1e1b..1d4c33e 100644
--- a/2d/vector.scm
+++ b/2d/vector.scm
@@ -23,13 +23,28 @@
(define-module (2d vector)
#:use-module (rnrs base)
- #:export (v+
+ #:export (vx
+ vy
+ vz
+ v+
v*
scale
mag
normalize
vector-reduce))
+(define (vx vector)
+ "Returns the first element of a vector."
+ (vector-ref vector 0))
+
+(define (vy vector)
+ "Returns the second element of a vector."
+ (vector-ref vector 1))
+
+(define (vz vector)
+ "Returns the third element of a vector."
+ (vector-ref vector 2))
+
(define (v+ . vectors)
"Adds vectors."
(apply vector-map + vectors))