I don't think there is any right answer, which is probably why we all have
our own libraries. Horses for courses!
So far the only things I have needed sweep for is springs, ribbon cables
and flexible flat strips. For those only the flat strip needs a particular
orientation and that generally needs to be oriented in the direction of the
path. I.e. if I rotate my ribbon cable assembly 90 degrees it should look
the same, so the fixed starting rotation doesn't work for me. On the other
had I might have a skewed version as on the Mendel90 X axis. In which case
FS would not be the right orientation but I can easily rotate the profile
to undo the FS rotation. Or perhaps pass an addition parameter to disable
the FS rotation and use the identity.
I generally start with the simplest code I can imagine and only make it
more complicated when I find it is needed.
On Sat, 2 Feb 2019 at 14:05, nop head nop.head@gmail.com wrote:
Because [[1,0,0],[0,-1,0],[0,0,1]] is arbitrary, you can just as easily
flip it three other ways and be just as valid, and other nearly vertical
paths do, and so a minute variance in a path pointing almost straight down
cause a big change to the results, which I don't like.
Using FS means there is a single valid result and I can predict what it
will be.
On Sat, 2 Feb 2019 at 13:14, Parkinbot rudolf@digitaldocument.de wrote:
What if one just discriminates for the initial rotation alpha
if alpha == 180° then use [[1,0,0],[0,-1,0],[0,0,1],]
else if |180°-alpha|< threshold then apply e.g. a 90°-rotation to the
shape
and go on with relative rotations
else go on with relative rotations
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Your FS solution requires that sequence of collinear path points should be
avoided. I agree that repeated points should be filtered or generate an
error but would like to allow collinear sequence of path points.
Btw, how do you specify your ribbon cable path? I saw some of your images
where they have 45 degree folds. Is each wire sweep defined individually?
Yes each wire has the fold in a different position, so is a separate sweep.
This is why speed is very important to me.
I make the path out straight lines and arcs plus a Bezier curve in the
middle. That starts with a straight down section under clamps, which is why
the singularity is important to me. It doesn't matter for the wires because
they start horizontally but it does for the strip.
I join sections of path together with routines called before and after.
These take care of translating the start of one path to the end of the
other and removing the duplicate point where they meet.
Since there are big difference between the lengths of my straight segments
and the curved ones I calculate my tangents differently it seems. I
normalise the vectors before I subtract them and then normalise the
difference. That ensures the profile always bisects the angle between them,
regardless of their relative lengths.
This is what the top level code looks like:
module z_ribbon_cable(ways, depth, travel, pos, below, extra) {
min_z = -below + extra;
length = ceil(bezier_cable_length(depth, min_z, travel / 2));
thickness = cable_strip_thickness();
ct = inch(0.05);
depth2 = depth + thickness + ct;
steps = 50;
l2 = length + PI * (thickness + ct) / 2;
c3 = cable_strip_control_points(depth2, min_z, pos);
v3 = adjust_bezier_length(c3, l2);
h = sheet_thickness(table) + vero_z + vero_thickness(z_vb) + 7.4 / 2 -
vero_y;
h2 = sheet_thickness(spine) + vero_z + vero_thickness(z_vb2) + 7.4 / 2
vero_y;
loop = [[v3[0].x, v3[0].y, v3[0].z + extra + h], for(i = [0 : steps])
bezier(i / steps, v3)];
fold = after(arc_points(ct / 2, [0, -90, 0]), arc_points(ct / 2, [0, 0,
-90]));
short_bend = before(arc_points(vero_y, [90, 45, 90], al = 45), loop);
long_bend = before(before([[0, -6, 0], [0, 0, 0]], arc_points(vero_y,
[90, 0, 90])), loop);
bend2 = arc_points(vero_y, [180, 0, 180]);
short_tail = after(bend2, [[0, 0, 0], [0, -vero_y2 + vero_y - 6 + 8,
0]]);
long_tail = after(bend2, [[0, 0, 0], [0, -vero_y2 + vero_y - 6, 0]]);
for(i = [0 : ways - 1]) {
short = in([2, 3, 6, 7], i);
prefold = before([[0, 0, 0], [0, 0, extra + ribbon_fold_z + (ways -
1 - i) * ct]], fold);
allfold = after(prefold, [[0, 0, 0], [-(ribbon_x - spine_width / 2
ways * ct / 2) - h2 - i * ct, 0, 0]]);
tail = after(allfold, short ? short_tail : long_tail);
all = after(short ? short_bend : long_bend, tail);
color(i ? "grey" : "red")
translate([(i - (ways - 1) / 2) * ct, -thickness / 2 - ct / 2,
-extra])
sweep(all, circle_points(ct / 2 + eps));
if(i == 0)
ribbon_cable(ways, ceil(path_length(all)));
}
bezier_cable_strip(ways, depth, length, travel, pos, below, extra);
}
I am looking at ways to make it faster. Since the paths are the same before
and after the folded section (actually two variants because I leave some
wires unconnected for clearance for mains), I might try sweeping the start
to a mesh and duplicate the polyhedrons. The problem is OpenSCAD is
currently slow at drawing large identical polyhedrons, so I am waiting to
see how Hans' speed up work progresses.
It currently takes six seconds to compute this:
[image: cable.png]
It seems to be about 2 seconds to calculate the length of the strip and
sweep it, 2 seconds to compute the paths of the wires and 2 seconds to
sweep the wires.
I have realised that co-linear path points are needed to make straight but
twisted sweeps, which I don't currently have.
On Sat, 2 Feb 2019 at 18:00, Ronaldo Persiano rcmpersiano@gmail.com wrote:
Your FS solution requires that sequence of collinear path points should be
avoided. I agree that repeated points should be filtered or generate an
error but would like to allow collinear sequence of path points.
Btw, how do you specify your ribbon cable path? I saw some of your images
where they have 45 degree folds. Is each wire sweep defined individually?
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org