summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-10-26 13:38:10 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-10-26 13:38:10 -0400
commite7e99f52e9db96e1e9b77cf96b77f705e98cf70f (patch)
tree5aaad48574c82d4f6870b6357dc6b488fe038c1e
parent085087bdf97bda40e313a8a09f0d320ed355f86e (diff)
transform: Add transform-position procedure.
* sly/transform.scm (transform-position): New procedure.
-rw-r--r--sly/transform.scm9
1 files changed, 9 insertions, 0 deletions
diff --git a/sly/transform.scm b/sly/transform.scm
index 252c123..96b83e1 100644
--- a/sly/transform.scm
+++ b/sly/transform.scm
@@ -32,6 +32,7 @@
#:export (make-transform null-transform identity-transform
transform? transform-matrix
transpose transform-vector2
+ transform-position
transform+ transform*
scale translate rotate-x rotate-y rotate-z rotate
build-transform
@@ -101,6 +102,14 @@ column-major format."
(* y (array-ref m 1 1))
(array-ref m 1 3)))))
+(define (transform-position transform)
+ "Return a vector3 containing the positional data stored in
+TRANSFORM."
+ (let ((matrix (transform-matrix transform)))
+ (vector3 (array-ref matrix 3 0)
+ (array-ref matrix 3 1)
+ (array-ref matrix 3 2))))
+
(define (transform+ . transforms)
"Return the sum of all given transformation matrices. Return
null-transform if called without any arguments."