diff options
-rw-r--r-- | chickadee/math/quaternion.scm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/chickadee/math/quaternion.scm b/chickadee/math/quaternion.scm index 4df4ffd..cf2b4bc 100644 --- a/chickadee/math/quaternion.scm +++ b/chickadee/math/quaternion.scm @@ -23,7 +23,9 @@ (define-module (chickadee math quaternion) #:use-module (chickadee math) + #:use-module (ice-9 format) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) #:use-module (system foreign) #:export (quaternion quaternion? @@ -88,6 +90,15 @@ "Return the W coordinate of the quaternion Q." (quaternion-ref q 3)) +(define (display-quaternion q port) + (format port "#<quaterion ~f ~f ~f ~f>" + (quaternion-x q) + (quaternion-y q) + (quaternion-z q) + (quaternion-w q))) + +(set-record-type-printer! <quaternion> display-quaternion) + (define-inlinable (quaternion-magnitude q) "Return the magnitude of the quaternion Q." (sqrt |