From 72aae0e42c10d5b30bd5e317cd9942370b279f22 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Sat, 21 Mar 2020 09:19:49 -0400 Subject: [PATCH] Expanded sqr() to take lists and removed vsqr() --- math.scad | 11 +++++++---- vectors.scad | 7 ------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/math.scad b/math.scad index 4dfe845..92af87c 100644 --- a/math.scad +++ b/math.scad @@ -26,11 +26,14 @@ NAN = acos(2); // The value `nan`, useful for comparisons. // Usage: // sqr(x); // Description: -// Returns the square of the given number. +// Returns the square of the given number or entries in list // Examples: -// sqr(3); // Returns: 9 -// sqr(-4); // Returns: 16 -function sqr(x) = x*x; +// sqr(3); // Returns: 9 +// sqr(-4); // Returns: 16 +// sqr([3,4]); // Returns: [9,16] +// sqr([[1,2],[3,4]]); // Returns [[1,4],[9,16]] +// sqr([[1,2],3]); // Returns [[1,4],9] +function sqr(x) = is_list(x) ? [for(val=x) sqr(val)] : x*x; // Function: log2() diff --git a/vectors.scad b/vectors.scad index 9509b6c..ce82094 100644 --- a/vectors.scad +++ b/vectors.scad @@ -95,13 +95,6 @@ function vdiv(v1, v2) = [for (i = [0:1:len(v1)-1]) v1[i]/v2[i]]; function vabs(v) = [for (x=v) abs(x)]; -// Function: vsqr() -// Usage: -// x = vsqr(v); -// Description: -// Returns a vector where each value in the original given vector is squared. -function vsqr(v) = [for(i=v) i*i]; - // Function: unit() // Description: