summaryrefslogtreecommitdiff
path: root/sly/transform.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-10-23 18:46:17 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-10-23 18:46:17 -0400
commitdda297a7dfb9a39eedcd668ffdb395e7e90abd34 (patch)
treefb5e1d03bf527537a2a676c98338281b4363d23f /sly/transform.scm
parentdb942317cf742e4358ce46ddb77dcddba9e212a3 (diff)
Move rotate procedure to transform module.
* sly/quaternion.scm (rotate): Remove. * sly/transform.scm (rotate): New procedure.
Diffstat (limited to 'sly/transform.scm')
-rw-r--r--sly/transform.scm20
1 files changed, 19 insertions, 1 deletions
diff --git a/sly/transform.scm b/sly/transform.scm
index 95324ed..205ecbe 100644
--- a/sly/transform.scm
+++ b/sly/transform.scm
@@ -28,11 +28,12 @@
#:use-module (srfi srfi-42)
#:use-module (sly math)
#:use-module (sly math vector)
+ #:use-module (sly quaternion)
#:export (make-transform null-transform identity-transform
transform? transform-matrix
transpose transform-vector2
transform+ transform*
- scale translate rotate-x rotate-y rotate-z
+ scale translate rotate-x rotate-y rotate-z rotate
orthographic-projection perspective-projection
look-at))
@@ -184,6 +185,23 @@ identity-transform if called without any arguments."
0 0 1 0
0 0 0 1))
+(define rotate
+ (match-lambda
+ (($ <quaternion> w x y z)
+ (make-transform
+ (- 1 (* 2 (square y)) (* 2 (square z)))
+ (- (* 2 x y) (* 2 w z))
+ (+ (* 2 x z) (* 2 w y))
+ 0
+ (+ (* 2 x y) (* 2 w z))
+ (- 1 (* 2 (square x)) (* 2 (square z)))
+ (- (* 2 y z) (* 2 w x))
+ 0
+ (- (* 2 x z) (* 2 w y))
+ (+ (* 2 y z) (* 2 w x))
+ (- 1 (* 2 (square x)) (* 2 (square y)))
+ 0 0 0 0 1))))
+
(define (orthographic-projection left right top bottom near far)
"Return a new transform that represents an orthographic projection
for the vertical clipping plane LEFT and RIGHT, the horizontal