summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)