diff options
-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 |