diff options
author | David Thompson <dthompson2@worcester.edu> | 2017-08-13 13:54:17 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2017-09-13 21:16:30 -0400 |
commit | 40a66f2e11d4a180554845312684299c2c2cbd43 (patch) | |
tree | 9c27641be5b5a1d330eb6f97574c7a76a57748dc | |
parent | 03bd9eeffe52685cd6ca220761d4f8e44516b131 (diff) |
math: matrix: Add custom record type printer.
* chickadee/math/matrix.scm (display-matrix4): New procedure.
-rw-r--r-- | chickadee/math/matrix.scm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/chickadee/math/matrix.scm b/chickadee/math/matrix.scm index 26b70fe..2e94233 100644 --- a/chickadee/math/matrix.scm +++ b/chickadee/math/matrix.scm @@ -16,6 +16,7 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (chickadee math matrix) + #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (rnrs bytevectors) #:use-module (srfi srfi-9) @@ -52,6 +53,29 @@ (define-inlinable (matrix-ref matrix row column) (f32vector-ref matrix (+ (* row 4) column))) +(define (display-matrix4 matrix port) + (let ((m (matrix4-bv matrix))) + (format port + "#<matrix4 [[~f ~f ~f ~f] [~f ~f ~f ~f] [~f ~f ~f ~f] [~f ~f ~f ~f]]>" + (matrix-ref m 0 0) + (matrix-ref m 0 1) + (matrix-ref m 0 2) + (matrix-ref m 0 3) + (matrix-ref m 1 0) + (matrix-ref m 1 1) + (matrix-ref m 1 2) + (matrix-ref m 1 3) + (matrix-ref m 2 0) + (matrix-ref m 2 1) + (matrix-ref m 2 2) + (matrix-ref m 2 3) + (matrix-ref m 3 0) + (matrix-ref m 3 1) + (matrix-ref m 3 2) + (matrix-ref m 3 3)))) + +(set-record-type-printer! <matrix4> display-matrix4) + (define (init-matrix4 matrix aa ab ac ad ba bb bc bd |