diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-06-09 22:24:36 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-06-09 22:24:36 -0400 |
commit | ab68b1a6b2454585adbede7b4c5fb6a7c8d68650 (patch) | |
tree | 538032cb2230211fefa566ba5041a34868fe3b42 /2d | |
parent | 82cc6e27adc4ac06e1e429eeeaac0a73f597e66d (diff) |
Add rotation transformations for x and y axes.
* 2d/transform.scm (rotate-x, rotate-y, rotate-z): New
procedures.
(transform-rotate): Renamed.
(make-transform*): Use rotate-z for now.
Diffstat (limited to '2d')
-rw-r--r-- | 2d/transform.scm | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/2d/transform.scm b/2d/transform.scm index 8efd8be..09e4398 100644 --- a/2d/transform.scm +++ b/2d/transform.scm @@ -40,9 +40,8 @@ transform* transform-translate transform-scale - transform-rotate - orthographic-projection - perspective-projection)) + rotate-x rotate-y rotate-z + orthographic-projection perspective-projection)) (define-record-type <transform> (%make-transform matrix) @@ -83,7 +82,7 @@ column-major format." given TRANSLATE, SCALE, and ROTATE values. Both TRANSLATE and SCALE are vector2 values, while ROTATE is a number." (transform* (transform-scale scale) - (transform-rotate rotate) + (rotate-z rotate) (transform-translate translate))) (define null-transform @@ -166,7 +165,20 @@ V." 0 0 1 0 0 0 0 1)) -(define (transform-rotate angle) +(define (rotate-x angle) + "Return a new transform that rotates the X axis by ANGLE radians." + (make-transform 1 0 0 0 + 0 (cos angle) (- (sin angle)) 0 + 0 (sin angle) (cos angle) 0 + 0 0 0 1)) + +(define (rotate-y angle) + "Return a new transform that rotates the Y axis by ANGLE radians." + (make-transform (cos angle) 0 (sin angle) 0 + 0 1 0 0 + (- (sin angle)) 0 (cos angle) 0 + 0 0 0 1)) +(define (rotate-z angle) "Return a new transform that rotates the Z axis by ANGLE radians." (make-transform (cos angle) (- (sin angle)) 0 0 (sin angle) (cos angle) 0 0 |