summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/math/matrix.scm30
1 files changed, 30 insertions, 0 deletions
diff --git a/chickadee/math/matrix.scm b/chickadee/math/matrix.scm
index 3e73f0c..27b2fc7 100644
--- a/chickadee/math/matrix.scm
+++ b/chickadee/math/matrix.scm
@@ -42,6 +42,10 @@
matrix4-scale
matrix4-rotate!
matrix4-rotate
+ matrix4-rotate-x!
+ matrix4-rotate-x
+ matrix4-rotate-y!
+ matrix4-rotate-y
matrix4-rotate-z!
matrix4-rotate-z
matrix4-2d-transform!
@@ -367,6 +371,32 @@ clipping plane NEAR and FAR."
(matrix4-rotate! matrix q)
matrix))
+(define (matrix4-rotate-x! matrix angle)
+ (init-matrix4 matrix
+ 1.0 0.0 0.0 0.0
+ 0.0 (cos angle) (- (sin angle)) 0.0
+ 0.0 (sin angle) (cos angle) 0.0
+ 0.0 0.0 0.0 1.0))
+
+(define (matrix4-rotate-x angle)
+ "Return a new matrix that rotates about the X axis by ANGLE radians."
+ (let ((matrix (make-null-matrix4)))
+ (matrix4-rotate-x! matrix angle)
+ matrix))
+
+(define (matrix4-rotate-y! matrix angle)
+ (init-matrix4 matrix
+ (cos angle) 0.0 (- (sin angle)) 0.0
+ 0.0 1.0 0.0 0.0
+ (sin angle) 0.0 (cos angle) 0.0
+ 0.0 0.0 0.0 1.0))
+
+(define (matrix4-rotate-y angle)
+ "Return a new matrix that rotates about the Y axis by ANGLE radians."
+ (let ((matrix (make-null-matrix4)))
+ (matrix4-rotate-y! matrix angle)
+ matrix))
+
(define (matrix4-rotate-z! matrix angle)
(init-matrix4 matrix
(cos angle) (- (sin angle)) 0.0 0.0