diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-06-20 08:00:24 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-06-20 08:01:21 -0400 |
commit | 7f5b8242552fa4792420302f7765f172108835bd (patch) | |
tree | c776f4177b211d115ecf5ac0edd9bcc459c4d967 /2d | |
parent | c8e2b160356afb500c9e2eaeb62279aa2bbc9fd4 (diff) |
Add support for 3D vectors and scalars in scale procedure.
* 2d/transform.scm (scale): Support 3D vectors and scalars as arguments.
Diffstat (limited to '2d')
-rw-r--r-- | 2d/transform.scm | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/2d/transform.scm b/2d/transform.scm index 9b7e05d..a1c05ea 100644 --- a/2d/transform.scm +++ b/2d/transform.scm @@ -140,12 +140,31 @@ vector V." (vx v) (vy v) 0 1)) (define (scale v) - "Return a new transform that scales the X and Y axes by the vector -V." - (make-transform (vx v) 0 0 0 - 0 (vy v) 0 0 - 0 0 1 0 - 0 0 0 1)) + "Return a new transform that scales by the 2D vector, 3D vector, or +scalar V." + (cond + ((number? v) + (make-transform v 0 0 0 + 0 v 0 0 + 0 0 v 0 + 0 0 0 1)) + ((vector2? v) + (let ((x (vx v)) + (y (vy v))) + (make-transform x 0 0 0 + 0 y 0 0 + 0 0 1 0 + 0 0 0 1))) + ((vector3? v) + (let ((x (vx v)) + (y (vy v)) + (z (vz v))) + (make-transform x 0 0 0 + 0 y 0 0 + 0 0 z 0 + 0 0 0 1))) + (else + (error "Invalid scaling vector: " v)))) (define (rotate-x angle) "Return a new transform that rotates the X axis by ANGLE radians." |