summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-12-16 08:44:48 -0500
committerDavid Thompson <dthompson2@worcester.edu>2020-12-16 08:44:48 -0500
commit4e5b59b1e672667b7aa8793469ba2f937a9be198 (patch)
treedf47ee197f64e41ab00b89951d9f39e861c5f11a
parent0b56068b9794313700a7bd041abd17a550e7a258 (diff)
math: matrix: Add procedures to extract translation from 4x4 matrix.
-rw-r--r--chickadee/math/matrix.scm14
1 files changed, 13 insertions, 1 deletions
diff --git a/chickadee/math/matrix.scm b/chickadee/math/matrix.scm
index 4616643..0f1e523 100644
--- a/chickadee/math/matrix.scm
+++ b/chickadee/math/matrix.scm
@@ -66,7 +66,10 @@
matrix4-2d-transform!
matrix4-transform-x
matrix4-transform-y
- matrix4-transform!))
+ matrix4-transform!
+ matrix4-x
+ matrix4-y
+ matrix4-z))
;;;
@@ -707,3 +710,12 @@ happens with respect to ORIGIN, a 2D vector."
(y (vec2-y v)))
(set-vec2-x! v (matrix4-transform-x matrix x y))
(set-vec2-y! v (matrix4-transform-y matrix x y))))
+
+(define-inlinable (matrix4-x matrix)
+ (matrix4-ref (matrix4-bv matrix) 3 0))
+
+(define-inlinable (matrix4-y matrix)
+ (matrix4-ref (matrix4-bv matrix) 3 1))
+
+(define-inlinable (matrix4-z matrix)
+ (matrix4-ref (matrix4-bv matrix) 3 2))