Skip to content

Commit 7b93b42

Browse files
fix handling of 180 deg arcs and n parameter
1 parent 1d9adaa commit 7b93b42

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drawing.scad

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ module dashed_stroke(path, dashpat=[3,3], width=1, closed=false, fit=true, round
701701
// the exact point count, you should use `$fs` and `$fa` to control the number of points on the roundings and arc. If you give `n` then each arc
702702
// section in your curve uses `n` points, so the total number of points is `n` times one plus the number of non-zero roundings you specified.
703703
// Arguments:
704-
// n = Number of vertices to use in the arc.
704+
// n = Number of vertices to use in the arc. If `wedge=true` you will get `n+1` points.
705705
// r = Radius of the arc.
706706
// angle = If a scalar, specifies the end angle in degrees (relative to start parameter). If a vector of two scalars, specifies start and end angles.
707707
// ---
@@ -900,7 +900,8 @@ function _rounded_arc(radius, rounding=0, angle, n) =
900900
rounding = force_list(rounding,3),
901901
dir = sign(angle),
902902

903-
inner_corner_radius = abs(angle)==180?0 : abs(angle)>180 ? -dir*rounding[0] : dir*rounding[0],
903+
// inner_corner_radius = abs(angle)==180?0 : abs(angle)>180 ? -dir*rounding[0] : dir*rounding[0],
904+
inner_corner_radius = abs(angle)>180 ? -dir*rounding[0] : dir*rounding[0],
904905
arc1_opt_radius = radius - rounding[1],
905906
arc2_opt_radius = radius - rounding[2],
906907
check = assert(rounding[1]<arc1_opt_radius, "rounding[1] is too big to fit")
@@ -923,11 +924,12 @@ function _rounded_arc(radius, rounding=0, angle, n) =
923924
assert(edge_gap1>=0, "Roundings are too large: center rounding (rounding[0]) interferes with first corner (rounding[1])")
924925
assert(edge_gap2>=0, "Roundings are too large: center rounding (rounding[0]) interferes with second corner (rounding[2])")
925926
[
926-
each if (rounding[0]>0) arc(cp=pt2,
927+
each if (rounding[0]>0 && abs(angle)!=180)
928+
arc(cp=pt2,
927929
points=[polar_to_xy(r=radius_of_ctrpt_edge, theta=angle), // origin corner curve
928930
polar_to_xy(r=radius_of_ctrpt_edge, theta=0)],
929931
endpoint=edge_gap1!=0,n=n)
930-
else [[0,0]],
932+
else repeat([0,0],rounding[0]>0 && abs(angle)==180 && is_def(n) ? n : 1),
931933
each if (rounding[1]>0) arc(r=rounding[1],cp=pt1,angle=[-90*dir,dir*arc1_angle],endpoint=dir*arc1_angle==angle,n=n), // first corner
932934
each if (arc1_angle+arc2_angle<abs(angle))
933935
arc(r=radius, angle=[dir*arc1_angle,angle - dir*arc2_angle], endpoint=rounding[2]==0,n=n), // main arc section

0 commit comments

Comments
 (0)