From 3de33f94c593a5b740dbb4096631b0b2971e2101 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 10 Sep 2018 17:12:09 -0400 Subject: math: vector: Fix vec2-normalize and vec3-normalize. * chickadee/math/vector.scm: Move vec2-normalize and vec3-normalize below the definitions of vec2-normalize! and vec3-normalize! so that inlining doesn't screw things up. --- chickadee/math/vector.scm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chickadee/math/vector.scm b/chickadee/math/vector.scm index da5eef2..a617910 100644 --- a/chickadee/math/vector.scm +++ b/chickadee/math/vector.scm @@ -220,18 +220,6 @@ polar coordinate (R, THETA)." (* (vec3-y v1) (vec3-y v2)) (* (vec3-z v1) (vec3-z v2)))) -(define (vec2-normalize v) - "Return the normalized form of the vec2 V." - (with-new-vec2 new - (vec2-copy! v new) - (vec2-normalize! new))) - -(define (vec3-normalize v) - "Return the normalized form of the vec3 V." - (with-new-vec3 new - (vec3-copy! v new) - (vec3-normalize! new))) - (define-inlinable (vec2-normalize! v) "Normalize the vec2 V in-place." (unless (and (zero? (vec2-x v)) (zero? (vec2-y v))) @@ -249,6 +237,18 @@ polar coordinate (R, THETA)." (set-vec3-y! v (/ (vec3-y v) m)) (set-vec3-z! v (/ (vec3-z v) m))))) +(define (vec2-normalize v) + "Return the normalized form of the vec2 V." + (with-new-vec2 new + (vec2-copy! v new) + (vec2-normalize! new))) + +(define (vec3-normalize v) + "Return the normalized form of the vec3 V." + (with-new-vec3 new + (vec3-copy! v new) + (vec3-normalize! new))) + (define-inlinable (vec2-mult! v x) "Multiply the vec2 V by X, a real number or vec2." (if (real? x) -- cgit v1.2.3