Skip to content

Commit b609e05

Browse files
Merge pull request #1893 from adrianVmariano/master
transforms doc fixes
2 parents b44fd1c + a9327bf commit b609e05

File tree

5 files changed

+40
-32
lines changed

5 files changed

+40
-32
lines changed

comparisons.scad

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ function deduplicate(list, closed=false, eps=_EPSILON) =
455455
l = len(list),
456456
end = l-(closed?0:1)
457457
)
458-
is_string(list) ? str_join([for (i=[0:1:l-1]) if (i==end || list[i] != list[(i+1)%l]) list[i]]) :
458+
is_string(list) ? chr([for (i=[0:1:l-1]) if (i==end || list[i] != list[(i+1)%l]) ord(list[i])]) :
459459
eps==0 ? [for (i=[0:1:l-1]) if (i==end || list[i] != list[(i+1)%l]) list[i]] :
460460
[for (i=[0:1:l-1]) if (i==end || !approx(list[i], list[(i+1)%l], eps)) list[i]];
461461

@@ -580,7 +580,7 @@ function list_unwrap(list, eps=_EPSILON) =
580580
// sorted = unique([true,2,"xba",[1,0],true,[0,0],3,"a",[0,0],2]); // Returns: [true,2,3,"a","xba",[0,0],[1,0]]
581581
function unique(list) =
582582
assert(is_list(list)||is_string(list), "Invalid input." )
583-
is_string(list)? str_join(unique([for (x = list) x])) :
583+
is_string(list)? chr(unique([for (x = list) ord(x)])) :
584584
len(list)<=1? list :
585585
is_homogeneous(list,1) && ! is_list(list[0])
586586
? _unique_sort(list)
@@ -840,7 +840,7 @@ function _indexed_sort(arrind) =
840840
// sorted3 = sort(l3); // Returns: [20,[3,1],[3,9],[4],[4,0],[7],[8]]
841841
function sort(list, idx=undef) =
842842
assert(is_list(list)||is_string(list), "Invalid input." )
843-
is_string(list)? str_join(sort([for (x = list) x],idx)) :
843+
is_string(list)? chr(sort([for (x = list) ord(x)])) :
844844
!is_list(list) || len(list)<=1 ? list :
845845
is_homogeneous(list,1)
846846
? let(size = list_shape(list[0]))

linalg.scad

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ function is_rotation(A,dim,centered=false) =
126126
// eps = numbers smaller than this display as zero. Default: 1e-9
127127
function echo_matrix(M,description,sig=4,sep=1,eps=1e-9) =
128128
let(
129-
horiz_line = chr(8213),
129+
horiz_line = 8213,
130130
matstr = _format_matrix(M,sig=sig,sep=sep,eps=eps),
131-
separator = str_join(repeat(horiz_line,10)),
131+
separator = chf(repeat(horiz_line,10)),
132132
dummy=echo(str(separator,is_def(description) ? str(" ",description) : ""))
133133
[for(row=matstr) echo(row)]
134134
)

masks.scad

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,8 @@ module face_profile(faces=[], r, d, excess=0.01, convexity=10) {
11851185
// Usage:
11861186
// PARENT() edge_profile([edges], [except], [convexity]) CHILDREN;
11871187
// Description:
1188-
// Takes a 2D mask shape and attaches it to the selected edges, with the appropriate orientation and
1188+
// Takes a 2D mask shape and attaches it to the selected edges of a cuboid, prismoid or cone, with the
1189+
// appropriate orientation and
11891190
// extruded length to be `diff()`ed away, to give the edge a matching profile. If no tag is set
11901191
// then `edge_profile` sets the tag for children to "remove" so that it works with the default {{diff()}} tag.
11911192
// For details on specifying the edges to mask see [Specifying Edges](attachments.scad#subsection-specifying-edges).
@@ -1223,7 +1224,8 @@ module face_profile(faces=[], r, d, excess=0.01, convexity=10) {
12231224

12241225
module edge_profile(edges=EDGES_ALL, except=[], excess=0.01, convexity=10) {
12251226
req_children($children);
1226-
check1 = assert($parent_geom != undef, "\nNo object to attach to!");
1227+
check1 = assert($parent_geom != undef, "\nNo object to attach to!")
1228+
assert(in_list($parent_geom[0],["conoid","prismoid"]), "Parent must be a cyl, cuboid or prismoid");
12271229
conoid = $parent_geom[0] == "conoid";
12281230
edges = !conoid? _edges(edges, except=except) :
12291231
edges==EDGES_ALL? [TOP,BOT] :
@@ -1552,9 +1554,14 @@ module edge_profile_asym(
15521554
[for (i=[0:2]) if (abs(e1[i])==1 && e1[i]==e2[i]) -e1[i] else 0];
15531555

15541556
req_children($children);
1557+
1558+
is_cuboid = is_def($parent_geom) && $parent_geom[0]=="prismoid"
1559+
&& point2d($parent_geom[1])==$parent_geom[2]
1560+
&& $parent_geom[3]==[0,0];
15551561
check1 = assert($parent_geom != undef, "\nNo object to attach to!")
1556-
assert(in_list(corner_type, ["none", "round", "chamfer", "sharp"]))
1557-
assert(is_bool(flip));
1562+
assert(is_cuboid, "Parent must be a cuboid")
1563+
assert(in_list(corner_type, ["none", "round", "chamfer", "sharp"]))
1564+
assert(is_bool(flip));
15581565
edges = _edges(edges, except=except);
15591566
vecs = [
15601567
for (i = [0:3], axis=[0:2])
@@ -2164,7 +2171,6 @@ module polygon_edge_mask(mask, length, height, l, h, scale=1, anchor="origin", a
21642171
angle = vector_angle(select(mask,corner-1,corner+1));
21652172
anchor_dir = -zrot(angle/2,RIGHT);
21662173
anchors = [named_anchor("corner", CTR,anchor_dir, _compute_spin(anchor_dir, UP))];
2167-
echo(anchors=anchors);
21682174
default_tag("remove")
21692175
attachable(anchor=anchor, spin=spin, orient=orient, h=length, scale=scale, path=mask, extent=atype=="hull", anchors=anchors){
21702176
linear_sweep(mask,h=length,anchor="origin", scale=scale);

partitions.scad

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ function left_half(p,x=0) = half_of(p, LEFT, [x,0,0]);
201201
// right_half(planar=true) circle(r=20);
202202
module right_half(s=100, x=0, planar=false)
203203
{
204+
req_children($children);
204205
dir = RIGHT;
205206
difference() {
206207
children();

strings.scad

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ function _is_liststr(s) = is_list(s) || is_str(s);
3737
// s5=substr("abcdefg",len=-2); // Returns ""
3838
function substr(str, pos=0, len=undef) =
3939
assert(is_string(str))
40-
is_list(pos) ? _substr(str, pos[0], pos[1]-pos[0]+1) :
41-
len == undef ? _substr(str, pos, len(str)-pos) :
42-
_substr(str,pos,len);
43-
44-
function _substr(str,pos,len,substr="") =
45-
len <= 0 || pos>=len(str) ? substr :
46-
_substr(str, pos+1, len-1, str(substr, str[pos]));
40+
is_list(pos) ? _substr(str, pos[0], pos[1]-pos[0]+1)
41+
: len == undef ? _substr(str, pos, len(str)-pos)
42+
: _substr(str,pos,len);
4743

44+
function _substr(str,pos,len) =
45+
assert(pos>=0,"pos value for substr() must be nonnegative")
46+
len <= 0 || pos>=len(str) ? ""
47+
:
48+
chr([for(i=[pos:pos+len-1]) ord(str[i])]);
49+
4850

4951
// Function: suffix()
5052
// Synopsis: Returns the last few characters of a string.
@@ -348,7 +350,7 @@ function str_pad(str,length,char=" ",left=false) =
348350
assert(is_str(char) && len(char)==1, "char must be a single character string")
349351
assert(is_bool(left))
350352
let(
351-
padding = str_join(repeat(char,length-len(str)))
353+
padding = chr(repeat(ord(char),length-len(str)))
352354
)
353355
left ? str(padding,str) : str(str,padding);
354356

@@ -393,7 +395,7 @@ function str_replace_char(str,char,replace) =
393395
// s=downcase("ABCdef"); // Returns "abcdef"
394396
function downcase(str) =
395397
assert(is_string(str))
396-
str_join([for(char=str) let(code=ord(char)) code>=65 && code<=90 ? chr(code+32) : char]);
398+
chr([for(char=str) let(code=ord(char)) code>=65 && code<=90 ? code+32 : code]);
397399

398400

399401
// Function: upcase()
@@ -411,7 +413,7 @@ function downcase(str) =
411413
// s=upcase("ABCdef"); // Returns "ABCDEF"
412414
function upcase(str) =
413415
assert(is_string(str))
414-
str_join([for(char=str) let(code=ord(char)) code>=97 && code<=122 ? chr(code-32) : char]);
416+
chr([for(char=str) let(code=ord(char)) code>=97 && code<=122 ? code-32 : code]);
415417

416418

417419
// Section: Random strings
@@ -433,8 +435,8 @@ function upcase(str) =
433435
// charset = string to draw the characters from. Default: characters from "0" to "z".
434436
// seed = random number seed
435437
function rand_str(n, charset, seed) =
436-
is_undef(charset)? str_join([for(c=rand_int(48,122,n,seed)) chr(c)])
437-
: str_join([for(i=rand_int(0,len(charset)-1,n,seed)) charset[i]]);
438+
is_undef(charset)? chr(rand_int(48,122,n,seed))
439+
: chr([for(i=rand_int(0,len(charset)-1,n,seed)) ord(charset[i])]);
438440

439441

440442

@@ -609,17 +611,16 @@ function parse_num(str) =
609611
// Example:
610612
// str(123456789012345); // Returns "1.23457e+14"
611613
// format_int(123456789012345); // Returns "123456789012345"
612-
// format_int(-123456789012345); // Returns "-123456789012345"
614+
// format_int(-123456789012345); // Returns "-123456789012345"
615+
// format_int(12,3); // Returns 012
613616
function format_int(i,mindigits=1) =
614617
i<0? str("-", format_int(-i,mindigits)) :
615618
let(i=floor(i), e=floor(log(i)))
616-
i==0? str_join([for (j=[0:1:mindigits-1]) "0"]) :
617-
str_join(
618-
concat(
619-
[for (j=[0:1:mindigits-e-2]) "0"],
620-
[for (j=[e:-1:0]) str(floor(i/pow(10,j)%10))]
621-
)
622-
);
619+
i==0? chr([for (j=[0:1:mindigits-1]) 48]) :
620+
chr([
621+
for (j=[0:1:mindigits-e-2]) 48,
622+
for (j=[e:-1:0]) 48+(floor(i/pow(10,j)%10))
623+
]);
623624

624625

625626
// Function: format_fixed()
@@ -715,7 +716,7 @@ function _format_matrix(M, sig=4, sep=1, eps=1e-9) =
715716
figure_dash = chr(8210),
716717
space_punc = chr(8200),
717718
space_figure = chr(8199),
718-
sep = is_num(sep) && sep>=0 ? str_join(repeat(space_figure,sep))
719+
sep = is_num(sep) && sep>=0 ? chr(repeat(ord(space_figure),sep))
719720
: is_string(sep) ? sep
720721
: assert(false,"Invalid separator: must be a string or positive integer giving number of spaces"),
721722
strarr=
@@ -832,7 +833,7 @@ function format(fmt, vals) =
832833
typ=="G"? upcase(format_float(val,default(prec,6))) :
833834
assert(false,str("Unknown format type: ",typ)),
834835
padlen = max(0,wid-len(unpad)),
835-
padfill = str_join([for (i=[0:1:padlen-1]) zero? "0" : " "]),
836+
padfill = chr([for (i=[0:1:padlen-1]) zero? 48 : 32]),
836837
out = left? str(unpad, padfill) : str(padfill, unpad)
837838
)
838839
out, raw

0 commit comments

Comments
 (0)