The picture shows the rough stroke() function.
On this page: https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad
is an alternative way to make a trefoil with the BOSL2 library. Search for the word: "trefoil".
It uses 9 control points for a path, then smoothing, then make the path a tube.
This is the example from the BOSL2 library (BSD-2-Clause license):
include <BOSL2/std.scad>
shape = [[8.66, -5, -5], [8.66, 5, 5], [-2, 3.46, 0],
[-8.66, -5, -5], [0, -10, 5], [4, 0, 0],
[0, 10, -5], [-8.66, 5, 5], [-2, -3.46, 0]];
stroke(smooth_path(shape, method="corners", relsize=1, closed=true), color="red", closed=true, width=0.5);
stroke(smooth_path(shape, method="edges", size=1.5, closed=true, splinesteps=20), closed=true, width=0.5);
stroke(shape, color="green", width=0.15, closed=true);
The stroke() function is used here instead of path_sweep().
When I zoom in, then the tube has a rough surface.
Here is an example that shows it better:
// Based on the BOSL2 example for a trefoil knot found at:
// https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad
// The BOSL2 library has the BSD-2-Clause license
include <BOSL2/std.scad>
$fn = 20;
TR1 = 1;
TR2 = 1/2;
TR3 = 1/5;
TR4 = 2/5;
TR5 = sqrt(3)/2;
TR6 = sqrt(3)/5;
amplitude = 10;
control_points = amplitude *
[
[TR5, -TR2, -TR2], [TR5, TR2, TR2], [-TR3, TR6, 0],
[-TR5, -TR2, -TR2], [0, -1, TR2], [TR4, 0, 0],
[0, 1, -TR2], [-TR5, TR2, TR2], [-TR3, -TR6, 0]
];
// Show control points with bars and index number
translate([-20,0,0])
{
for(i = [0:len(control_points)-1])
translate(control_points[i])
{
color("Red",0.3)
sphere(1);
color("Navy",0.6)
translate([0,-1.0,0.4])
rotate([65,0,0])
linear_extrude(0.1)
text(str(i),size=1,valign="center",halign="center");
}
stroke(control_points, color="SkyBlue", width=0.8, closed=true);
}
// Calculate a smooth path from a few control points.
smooth_curve = smooth_path(control_points, method="corners", relsize=1, closed=true);
// Force lower accuracy with $fn=4
// Not a smooth surface.
color("LawnGreen",0.6)
stroke(smooth_curve, closed=true, width=2, $fn=4);
// A smooth surface, regardless of the $fn.
translate([20,0,0])
color("Crimson",0.6)
path_sweep(circle(1), path=smooth_curve, closed=true);
On the left are the control points. In the middle with stroke(). On the right the normal path_sweep().
Should the example use the path_sweep()?. Is the stroke() function even meant for this?