mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 00:09:37 +00:00
change wiring radius to use round_corners instead of beziers
This commit is contained in:
parent
1547aa8f71
commit
1df2d49e3c
1 changed files with 5 additions and 8 deletions
13
wiring.scad
13
wiring.scad
|
@ -8,9 +8,7 @@
|
||||||
// FileSummary: Routed bundles of wires.
|
// FileSummary: Routed bundles of wires.
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
include <rounding.scad>
|
||||||
include <beziers.scad>
|
|
||||||
|
|
||||||
|
|
||||||
// Section: Functions
|
// Section: Functions
|
||||||
|
|
||||||
|
@ -77,10 +75,10 @@ function hex_offsets(n, d, lev=0, arr=[]) =
|
||||||
// wirediam = The diameter of each wire in the bundle.
|
// wirediam = The diameter of each wire in the bundle.
|
||||||
// rounding = The radius that the path corners will be rounded to.
|
// rounding = The radius that the path corners will be rounded to.
|
||||||
// wirenum = The first wire's offset into the color table.
|
// wirenum = The first wire's offset into the color table.
|
||||||
// bezsteps = The corner roundings in the path will be converted into this number of segments.
|
// corner_steps = The corner roundings in the path will be converted into this number of segments.
|
||||||
// Example:
|
// Example:
|
||||||
// wiring([[50,0,-50], [50,50,-50], [0,50,-50], [0,0,-50], [0,0,0]], rounding=10, wires=13);
|
// wiring([[50,0,-50], [50,50,-50], [0,50,-50], [0,0,-50], [0,0,0]], rounding=10, wires=13);
|
||||||
module wiring(path, wires, wirediam=2, rounding=10, wirenum=0, bezsteps=12) {
|
module wiring(path, wires, wirediam=2, rounding=10, wirenum=0, corner_steps=12) {
|
||||||
colors = [
|
colors = [
|
||||||
[0.2, 0.2, 0.2], [1.0, 0.2, 0.2], [0.0, 0.8, 0.0], [1.0, 1.0, 0.2],
|
[0.2, 0.2, 0.2], [1.0, 0.2, 0.2], [0.0, 0.8, 0.0], [1.0, 1.0, 0.2],
|
||||||
[0.3, 0.3, 1.0], [1.0, 1.0, 1.0], [0.7, 0.5, 0.0], [0.5, 0.5, 0.5],
|
[0.3, 0.3, 1.0], [1.0, 1.0, 1.0], [0.7, 0.5, 0.0], [0.5, 0.5, 0.5],
|
||||||
|
@ -89,14 +87,13 @@ module wiring(path, wires, wirediam=2, rounding=10, wirenum=0, bezsteps=12) {
|
||||||
[0.6, 0.6, 1.0],
|
[0.6, 0.6, 1.0],
|
||||||
];
|
];
|
||||||
offsets = hex_offsets(wires, wirediam);
|
offsets = hex_offsets(wires, wirediam);
|
||||||
bezpath = fillet_path(path, rounding);
|
rounded_path = round_corners(path, radius=rounding,$fn=(corner_steps+1)*4,closed=false);
|
||||||
poly = path_merge_collinear(path3d(bezier_path(bezpath, bezsteps)));
|
|
||||||
n = max(segs(wirediam), 8);
|
n = max(segs(wirediam), 8);
|
||||||
r = wirediam/2;
|
r = wirediam/2;
|
||||||
for (i = [0:1:wires-1]) {
|
for (i = [0:1:wires-1]) {
|
||||||
extpath = [for (j = [0:1:n-1]) let(a=j*360/n) [r*cos(a)+offsets[i][0], r*sin(a)+offsets[i][1]]];
|
extpath = [for (j = [0:1:n-1]) let(a=j*360/n) [r*cos(a)+offsets[i][0], r*sin(a)+offsets[i][1]]];
|
||||||
color(colors[(i+wirenum)%len(colors)]) {
|
color(colors[(i+wirenum)%len(colors)]) {
|
||||||
path_sweep(extpath, poly);
|
path_sweep(extpath, rounded_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue