mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-28 15:59:45 +00:00
Expanded sqr() to take lists and removed vsqr()
This commit is contained in:
parent
79358ddf6f
commit
72aae0e42c
2 changed files with 7 additions and 11 deletions
11
math.scad
11
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()
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue