From dba563f8b17ce2a543ef98c1bd64b68f5c5272c6 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 28 Aug 2020 22:07:21 -0400 Subject: math: Delete square procedure. It's just not useful. --- chickadee/math.scm | 4 ---- chickadee/math/vector.scm | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/chickadee/math.scm b/chickadee/math.scm index b970526..c61b862 100644 --- a/chickadee/math.scm +++ b/chickadee/math.scm @@ -20,7 +20,6 @@ pi/2 2pi cotan - square clamp min max @@ -37,9 +36,6 @@ "Return the cotangent of Z." (/ 1.0 (tan z))) -(define-inlinable (square x) - (* x x)) - (define-inlinable (clamp min max x) "Restrict X to the range defined by MIN and MAX. Assumes that MIN is actually less than MAX." diff --git a/chickadee/math/vector.scm b/chickadee/math/vector.scm index 31aff07..2269486 100644 --- a/chickadee/math/vector.scm +++ b/chickadee/math/vector.scm @@ -212,13 +212,13 @@ polar coordinate (R, THETA)." (define-inlinable (vec2-magnitude v) "Return the magnitude of the vec2 V." - (sqrt (+ (square (vec2-x v)) (square (vec2-y v))))) + (sqrt (+ (* (vec2-x v) (vec2-x v)) (* (vec2-y v) (vec2-y v))))) (define-inlinable (vec3-magnitude v) "Return the magnitude of the vec3 V." - (sqrt (+ (square (vec3-x v)) - (square (vec3-y v)) - (square (vec3-z v))))) + (sqrt (+ (* (vec3-x v) (vec3-x v)) + (* (vec3-y v) (vec3-y v)) + (* (vec3-z v) (vec3-z v))))) (define-inlinable (vec2-dot-product v1 v2) "Return the dot product of the vec2s V1 and V2." -- cgit v1.2.3