diff options
author | David Thompson <dthompson2@worcester.edu> | 2017-11-12 21:48:15 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2017-11-12 21:48:15 -0500 |
commit | b087e44c8e5ebed07a25cef43552ff3662e0c3c6 (patch) | |
tree | 9dd6ec0dea39086eedc7fbe5065bda3fea7e1299 | |
parent | 9772929c5910cc274a9c63621e6cb27c96597174 (diff) |
math: matrix: Allow translation with 3D vectors.
* chickadee/math/matrix.scm (matrix4-translate!): Add support for
the vec3 type.
-rw-r--r-- | chickadee/math/matrix.scm | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/chickadee/math/matrix.scm b/chickadee/math/matrix.scm index 1d59674..b257069 100644 --- a/chickadee/math/matrix.scm +++ b/chickadee/math/matrix.scm @@ -297,11 +297,19 @@ clipping plane NEAR and FAR." 0 0 (/ (* 2 far near) (- near far)) 0))) (define (matrix4-translate! matrix v) - (init-matrix4 matrix - 1.0 0.0 0.0 0.0 - 0.0 1.0 0.0 0.0 - 0.0 0.0 1.0 0.0 - (vec2-x v) (vec2-y v) 0.0 1.0)) + (cond + ((vec2? v) + (init-matrix4 matrix + 1.0 0.0 0.0 0.0 + 0.0 1.0 0.0 0.0 + 0.0 0.0 1.0 0.0 + (vec2-x v) (vec2-y v) 0.0 1.0)) + ((vec3? v) + (init-matrix4 matrix + 1.0 0.0 0.0 0.0 + 0.0 1.0 0.0 0.0 + 0.0 0.0 1.0 0.0 + (vec3-x v) (vec3-y v) (vec3-z v) 1.0)))) (define (matrix4-translate v) (let ((matrix (make-null-matrix4))) |