summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-10-11 18:42:56 -0400
committerDavid Thompson <dthompson2@worcester.edu>2019-10-11 18:42:56 -0400
commit0f9508b40f5a187fc23f177e3448ac7b668c6f52 (patch)
treead8d76dff0b9891d14e21e0930155b9b08c2fb20
parentc96755203de5db668d4aba3d5aec90053c13296d (diff)
math: vector: Add vec3 arithmetic procedures.
-rw-r--r--chickadee/math/vector.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/chickadee/math/vector.scm b/chickadee/math/vector.scm
index cbba1e6..41c7659 100644
--- a/chickadee/math/vector.scm
+++ b/chickadee/math/vector.scm
@@ -58,6 +58,9 @@
set-vec3-y!
set-vec3!
vec3-normalize!
+ vec3*
+ vec3+
+ vec3-
vec3-mult!
vec3-add!
vec3-sub!))
@@ -339,6 +342,24 @@ polar coordinate (R, THETA)."
(vec2-sub! new x)
new))
+(define-inlinable (vec3* v x)
+ "Multiply V by X."
+ (let ((new (vec3-copy v)))
+ (vec3-mult! new x)
+ new))
+
+(define-inlinable (vec3+ v x)
+ "Add X to V."
+ (let ((new (vec3-copy v)))
+ (vec3-add! new x)
+ new))
+
+(define-inlinable (vec3- v x)
+ "Subtract X from V."
+ (let ((new (vec3-copy v)))
+ (vec3-sub! new x)
+ new))
+
;; Reader macro for vectors.
(define (read-vec chr port)
(define (consume-whitespace port)