diff options
-rw-r--r-- | chickadee/math/vector.scm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/chickadee/math/vector.scm b/chickadee/math/vector.scm index 89b4f33..cdc9b82 100644 --- a/chickadee/math/vector.scm +++ b/chickadee/math/vector.scm @@ -16,8 +16,10 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (chickadee math vector) + #:use-module (ice-9 format) #:use-module (rnrs bytevectors) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) #:use-module (system foreign) #:use-module (chickadee math) #:export (vec2 @@ -163,6 +165,16 @@ polar coordinate (R, THETA)." "Set the z coordinate of the vec3 V to Z." (vec3-set! v 2 z)) +(define (display-vec2 v port) + (format port "#<vec2 x: ~f y: ~f>" (vec2-x v) (vec2-y v))) + +(set-record-type-printer! <vec2> display-vec2) + +(define (display-vec3 v port) + (format port "#<vec3 x: ~f y: ~f z: ~f>" (vec3-x v) (vec3-y v) (vec3-z v))) + +(set-record-type-printer! <vec3> display-vec3) + (define (vec2-copy! source-vec2 target-vec2) "Copy TARGET-VEC2 to SOURCE-VEC2." (set-vec2-x! target-vec2 (vec2-x source-vec2)) |