rew wrote
If I could see a need for avoiding discontinuities in curvature I am sure
I
could work something out with Bezier splines but life is too short. I use
Bezier splines to approximate minimum energy curves to model bent strips.
2D Bezier curves are easy in OpenSCAD, and 3D Bezier curves are certainly
possible with polyhedron. I don't think new primitives are needed.
At first I didn't think so, then I did, now I do....
It would be VERY nice if a recursive bezier module could be built. But
that requires returning "patches" that will build up to the sides of a
polyhedron. Writing out the recursion by hand and implementing the
stack on an array is very tedious. It's like on the first day of work
you new boss points at an actual Turing machine, and says: "that's
just as turing-complete as that windows machine over there, you can
use the turing machine."
It's theoretically possible, but WAY more convenient if there is some
language support.
If it's "theoretically possible" then after someone does it you can use the
code and you don't really care how hard it was to write. (How hard is it to
write into OpenSCAD as a primitive?) OpenSCAD can do recursion, so why
would you want to maintain your own stack? What is it that you think can't
be done? Or maybe more to the point, what exactly would your desired module
do? Maybe we can write it.
--
Sent from: http://forum.openscad.org/
On Wed, Mar 13, 2019 at 11:41:30AM +0000, nop head wrote:
Isn't it just some for loops and list comprehension? I don't think it is
much harder than sweep if you want a regular array of surface points.
Hmm.. Ok. Maybe it's doable... I'll give it a go later on. Maybe this
weekend. Feel free to remind me. I might forget.
(I already wrote the first test-control-points and the call of the
module, and the level zero approximation.... )
Roger.
On Wed, 13 Mar 2019, 11:00 Rogier Wolff <R.E.Wolff@bitwizard.nl wrote:
On Tue, Mar 12, 2019 at 11:28:24PM +0000, nop head wrote:
I don't have an artistic bone in my body, so to me circles meeting
tangents
are fine. I don't have any Apple products and probably never will as they
are just a waste of money. They look nice but are very unreliable and
locked in.
If I could see a need for avoiding discontinuities in curvature I am
sure I
could work something out with Bezier splines but life is too short. I use
Bezier splines to approximate minimum energy curves to model bent strips.
2D Bezier curves are easy in OpenSCAD, and 3D Bezier curves are certainly
possible with polyhedron. I don't think new primitives are needed.
At first I didn't think so, then I did, now I do....
It would be VERY nice if a recursive bezier module could be built. But
that requires returning "patches" that will build up to the sides of a
polyhedron. Writing out the recursion by hand and implementing the
stack on an array is very tedious. It's like on the first day of work
you new boss points at an actual Turing machine, and says: "that's
just as turing-complete as that windows machine over there, you can
use the turing machine."
It's theoretically possible, but WAY more convenient if there is some
language support.
Roger.
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110
**
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.
William Adams-2 wrote
Would it be possible to use this tool to get rounding as is done in some
industrial designs?
https://hackernoon.com/apples-icons-have-that-shape-for-a-very-good-reason-720d4e7c8a14
If not, could someone suggest a suitable technique to achieve this?
William
I studied Bezier curves last night (about which I knew nothing) and figured
out how cubic bezier curves can be used to achieve continuous curvature
rounding. One parameter needs to be specified at each corner. I'm
wondering what the best way to specify this parameter is. It could be
specified as the distance to the intersection point of the bezier with the
edge. Or it could be specified as the distance from the corner tip to the
maximum projection of the curve (e.g. how much is cut off). Or perhaps
some other way relating to rounding with circular arcs?
I also wonder if it might be desirable to round in a continuous curvature
fashion but more aggressively using a higher order Bezier. These roundovers
with the cubic bezier are rather gentle. Anybody know how to calculate the
curvature at the endpoints of an order 4 (or general order) bezier?
Here are two examples. The green line shows the bezier curve fit to the
corner shown in red. Note how far back it extends before finally
terminating on the linear portion? It means you need a long flat edge to
have room for a fairly modest roundover.
http://forum.openscad.org/file/t2477/bez.png
--
Sent from: http://forum.openscad.org/
I have not looked at the detailed properties, but Catmull–Rom
spline have the nice benefit that they don't need additional
control points. So for "just rounding stuff" that seems to be
quite interesting.
ciao,
Torsten.
tp3 wrote
I have not looked at the detailed properties, but Catmull–Rom
spline have the nice benefit that they don't need additional
control points. So for "just rounding stuff" that seems to be
quite interesting.
I also didn't look in detail, but it's not apparent that these splines have
any nice derivative properties, like even first derivative control. Having
no control parameters isn't necessary a good thing, as indicated by the
cubic bezier, which I think doesn't produce a curved enough roundover.
I did a little more analysis and I think a good way to do continuous
curvature roundovers is to use order 4 beziers. This ends up providing two
parameters. I'm still not sure of the optimal way to expose these
parameters to the user. Basically with these beziers you set p0 to one end
point, p4 to the other endpoint, p2 to the point of the corner, and the
remaining p1 and p3 are symmetrically placed on the intervals [p0,p2] and
[p2,p4]. The parameters that need to be chosen are the distance, d, of p0
and p4 from the corner and the distance a, of p1 and p2 from the corner.
Choosing a=d gives the maximum roundover, which I think is probably what is
generally desired. If we consider doing a chamfer by simply connecting p0
and p4 then the roundover that results from a=d will put the tip of the
roundover at 5/8 of the way from the corner point to the chamfer. Setting
a=0 puts the roundover 1/8 of the way from the corner to the chamfer.
So I could have the user specify d (the distance along the line segment to
the start of the roundover curve) or I could have the user specify the
distance to the line between p0 and p4. And for a I can have the user
specify a value on [0,1] to control the range from 0 to d, or I could have
the user specify something from [1/8 to 5/8]*d---specifying the actual
location of the roundover tip.
Maybe I'll post some pictures later since I think the above may not be
clear.
--
Sent from: http://forum.openscad.org/
http://forum.openscad.org/file/t2477/diagram.jpg So there's an image
showing a corner to be smoothed. The control points p0, ..., p4 are located
as shown, with p0 and p4 at the base of the bezier curve, p2 at the tip of
the corner, and p1 and p3 on the line segment in between somewhere. It
takes two parameters to specify the 4th order curve: d, the distance from
the corner (p2) to the base control points (p0 and p4) and a, the distance
to the secondary control points p1 and p3. The most rounding occurs when
a=d, at which point c = (5/8)*h. The least rounding occurs when a=0, at
which point c=(1/8)*h. So the user could specify d or h. Which is more
natural? For the amount of curvature the user could specify a (which
seems not very meaningful) or a/d which is a sort of smoothing factor
that ranges on [0,1] c, how much of the corner to "cut off" (but must be
in the range [1/8,5/8]*h the amount to cut off as a fraction of h, so a
value in the range [1/8, 5/8]
--
Sent from: http://forum.openscad.org/
You are right, a degree 3 Bezier arc would at most be zero curvature at one
extreme and tangent continuous at the other. The minimal degree for a zero
curvature at each extremes is really 5. However, I would use a degree 6
Bezier arc because you get too restricted setting p2 to the vertex of the
polygon. I did a experiment with degree 6 with the following strategy.
[image: pc.PNG]
The collinearity of P0, P1 and P2 implies zero curvature of the arc at P0
besides the tangent to segment [C.P0] (similarly for P5) .
The position of P2 (respect. P3) follows a ratio r0 in the interval (0,1)
in the segment [C,P0] (respect. [C,P5]).
The position of P1 (respect. P4) follows a ratio r1 in the interval (0,1)
in the segment [P2,P0] (respect. [P3,P5]).
This two ratios give some flexibility to the shape of the curve.
Here is a code that follows that strategy to round a polygon. I haven't
tried with non-convex polygons but it should work fine.
// polygon to be rounded
q = [ [0,0], [30,0], [15,20] ];
color("blue") roundedPoly(q, 20, 1/5);
color("yellow") roundedPoly(q, 20, 1/3);
color("red") roundedPoly(q, 20, 1/2);
translate([30,0,0]) {
color("blue") roundedPoly(q, 20, 1/5, 1/3);
color("yellow") roundedPoly(q, 20, 1/3, 1/3);
color("red") roundedPoly(q, 20, 1/2, 1/3);
}
module roundedPoly(p, n=20, r=1/4, r0=2/3, r1=1/2) {
assert(len(p)>2, "polygonal has less than 3 points");
assert(r>0 && r<1, "improper value of argument r");
l = len(p);
q = [for(i=[0:l-1])
let( p0 = (1-r)p[i] + rp[(i+l-1)%l] ,
p1 = p[i],
p2 = (1-r)p[i] + rp[(i+1)%l] )
each BZeroCurvature(p0,p1,p2,n,r0,r1) ];
line(q, closed=true);
}
// a Bezier arc of degree 5 from p0 to p2, tangent to
// [p0,p1] at p0, tangent to [p1,p2) at p2 and
// with zero curvature at p0 and p2
// n = # of points in the arc
// r0, r1 - form factors in the open interval (0,1)
function BZeroCurvature(p0,p1,p2,n=20,r0=2/3,r1=1/2) =
assert(r0>0 && r0<1 && r1>0 && r1<1, "improper value of r0 or r1")
let( p = [ p0,
p0 + r0*(p1-p0)r1,
p0 + r0(p1-p0),
p2 + r0*(p1-p2),
p2 + r0*(p1-p2)*r1,
p2 ] )
BezierCurve(p,n);
// p are the curve control points, the curve degree is len(p)-1
function BezierCurve(p, n=10) =
[for(i=[0:n-1]) BezierPoint(p, i/(n-1)) ];
function BezierPoint(p, u) =
(len(p) == 2)?
u*p[1] + (1-u)p[0] :
uBezierPoint([for(i=[1:len(p)-1]) p[i] ], u)
+ (1-u)*BezierPoint([for(i=[0:len(p)-2]) p[i] ], u);
module line(p,closed=false,w=0.1)
for(i=[0:len(p)-(closed? 1:2)]){
hull(){ translate(to3d(p[i])) sphere(w);
translate(to3d(p[(i+1)%len(p)])) sphere(w); }
}
function to3d(p) = len(p)==3 ? p : [p.x,p.y,0];
[image: roundedPoly.PNG]
I would not expect any good interface for Bezier stuffs could be designed
to solve a large set of problems to justify its implementation in the core
of OpenSCAD. Each modeling problem requires specific codes to be written
and that is easily done in users space if you have the needed mathematical
background. Anyway, to work with Bezier curves and surfaces, even using
other people good libraries, a minimal mathematical background is necessary.
I missed to mention that the argument r of roundedPoly() controls how much
of the corners are rounded. It has an effect similar to radius when
circular arcs are used.
Ronaldo wrote
You are right, a degree 3 Bezier arc would at most be zero curvature at
one
extreme and tangent continuous at the other. The minimal degree for a zero
curvature at each extremes is really 5. However, I would use a degree 6
Bezier arc because you get too restricted setting p2 to the vertex of the
polygon. I did a experiment with degree 6 with the following strategy.
I'm a little puzzled. Maybe you are using the word degree differently than
I think? I was thinking a degree 3 Bezier is a cubic polynomial and has 4
control points. It can be set to zero curvature at both ends but has only
one degree of freedom, which just controls the size of the curve. That
isn't enough. It appears to me that degree 4, with 5 control points, is
sufficient. Yes, you do need to put p2 on the vertex. This doesn't seem to
cause any undesirable restriction, and it is definitely possible to satisfy
the zero curvature condition. One parameter remains that controls the
degree of curvature, as I noted in my previous message. Having fewer
parameters is often better than more, so I'm not sure about what the value
of more degrees of freedom is of going to the case with 6 control points
(which is a 5th degree polynomial). I did experiment a bit with your code
and you can get some rather sharp cornered results. It seemed like r1
usually had little effect.
--
Sent from: http://forum.openscad.org/
On Wed, Mar 13, 2019 at 12:52:07PM +0100, Rogier Wolff wrote:
On Wed, Mar 13, 2019 at 11:41:30AM +0000, nop head wrote:
Isn't it just some for loops and list comprehension? I don't think it is
much harder than sweep if you want a regular array of surface points.
Hmm.. Ok. Maybe it's doable... I'll give it a go later on. Maybe this
weekend. Feel free to remind me. I might forget.
[... I already wrote .. ]
wrong!
I started over. I now have a bezier curve in 2D. This is at $fn = 15,
the parameter has not yet been added to the function.
Roger.
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.