summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
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))