BelfrySCAD / BOSL2

The Belfry OpenScad Library, v2.0. An OpenSCAD library of shapes, masks, and manipulators to make working with OpenSCAD easier. BETA
https://github.com/BelfrySCAD/BOSL2/wiki
BSD 2-Clause "Simplified" License
1.01k stars 115 forks source link

[BUG] offset_stroke() "round" ending gives pointed ending. #1391

Closed lijon closed 9 months ago

lijon commented 9 months ago

Describe the bug

See the wiki example https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-offset_stroke

The end="round" still gives a pointed end.

adrianVmariano commented 9 months ago

Which example specifically? Everything appears OK to me.

lijon commented 9 months ago

It's Example 1:

include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
arc = arc(points=[[1,1],[3,4],[6,3]],n=50);
path = [[0,0],[6,2],[9,7],[8,10]];
xdistribute(spacing=10){
  offset_stroke(path, width = 2);
  offset_stroke(path, start="round", end="round", width = 2);
  offset_stroke(path, start="pointed", end="pointed", width = 2);
}
fwd(10) xdistribute(spacing=10){
  offset_stroke(arc, width = 2);
  offset_stroke(arc, start="round", end="round", width = 2);
  offset_stroke(arc, start="pointed", end="pointed", width = 2);
}

The second stroke is supposed to have rounded ends. But as can be seen in the image, they are pointed.

lijon commented 9 months ago

adrianVmariano commented 9 months ago

Looks like $fn is too small. There used to be a bug where arc used the total number of points for a circle for its arc, no matter how short the arc. That probably made this example work in the past without setting $fn.

adrianVmariano commented 9 months ago

Fixed this in the example.

lijon commented 9 months ago

So is it only using $fn? Perhaps it should use segs()?

adrianVmariano commented 9 months ago

It computed the number of segments on the circle I think using segs() but then put that number of segments on the arc instead of dividing by the fraction of the circle that the arc occupied. Current version should be correct.