loop_extrude() to get curves with smooth tangents at points

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|

loop_extrude() to get curves with smooth tangents at points

John Griessen
I've been using Ruud Vlaming's loop_extrude() fork and wonder if anyone knows how
to get zero derivative crossings at points?  IOW, no discontinuities at points,
so one could define a curve by points and have it all be smooth for a milling machine with
a certain finite bit to mill in one pass.

This is my experiment in figuring out the bezier curve syntax,
and her is the diagonal view of that rendered:

http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt.png

loop_extrude(
points=["polar",[20,0],[25,15],[25,90],[25,165],[20,180],[25,195],[25,270],[25,345]],
vertices=[1,5,["arc",2.5],8,["arc",2,1-.3],2,4,6,3,7,["def"]],
edges=[3,7,["bez","csxy",[-.001,-.703]],2,6,["bez","csxy",[0,-.703]]],
$fn=30)
square(2.0, $fn=30);

I'd like to know if it is possible to specify points and get a smooth bezier to
include them.  I don't want to have the points off the path, but rather on the
path that has a few points to define it.

John
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves with smooth tangents at points

devlaam
Hi John,

It is not completely clear to me what you try to achieve,
but here are a few tips:

If you need to be continuously differentiable (CD) at the
location of the vertex, do not try to 'match' deformed edges.
Rather, modify the vertex itself. Vertex-edge coupling is CD
at using bezier by design. For example:

   loop(rect=[[8,6]], vertices=[["bez",2,2,0.7]], $fn=50);

Thus, if you need a curved structure modify the
vertices and let the edges shrink. In this way
you can even define a circle, starting from a square:

   loop(poly=[4,[6]], vertices=[["arc",2.999]], $fn=50);

So, let go of the idea that the edges are the 'long'
part and vertices the 'short', there is really no
need for that.

Of course, you can define an edge using a bezier,
and obtain a CD vertex, but then make sure that
the imaginary line through the control points around
the vertex crosses that vertex, like this:

   loop(rect=[[8,6]], edges=[1,["bez",[7,-1]],2,["bez",[9,1]]], $fn=50);

The hard parts are these:
(1) a line build using bezier points, does not cross
     those points, so it is difficult to define a
     particular trajectory.
(2) If you want to use a relative coordinate system,
     keeping the control points at the correct location
     can be really difficult.

At this moment the loop function does not have the
possibility to draw automatically a poly spline
through a series of points. This can be added, but
i doubt if it would be of great benefit. The problem
is that the curve in between still has much degrees
of freedom that have to be parametrized somehow,
and can exhibit wild behavior. Besides that,
exactly the same result can be achieved using
bezier around all vertices.

BTW, your definition of vertices

 > vertices=[1,5,["arc",2.5],8,["arc",2,1-.3],2,4,6,3,7,["def"]],

is a little 'overkill', this will do just the same:

   vertices=[1,5,["arc",2.5],8,["arc",2,1-.3]]

An other point that caught my eye is that you
have vertices that are so sharp that the extruder
cannot fit your square in there. A warning should be
issued  (only the first time, when the object is not
yet in cache) Please see the documentation Loop.pdf
for some tricks how to handle these cases.

Hopefully this will get you going. If not,
please post a (hand)drawing indicating what you
try to achieve.

Have fun!
Ruud


On 15-10-13 03:31, John Griessen wrote:

> I've been using Ruud Vlaming's loop_extrude() fork and wonder if anyone knows how
> to get zero derivative crossings at points?  IOW, no discontinuities at points,
> so one could define a curve by points and have it all be smooth for a milling machine with
> a certain finite bit to mill in one pass.
>
> This is my experiment in figuring out the bezier curve syntax,
> and her is the diagonal view of that rendered:
>
> http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt.png
>
> loop_extrude(
> points=["polar",[20,0],[25,15],[25,90],[25,165],[20,180],[25,195],[25,270],[25,345]],
> vertices=[1,5,["arc",2.5],8,["arc",2,1-.3],2,4,6,3,7,["def"]],
> edges=[3,7,["bez","csxy",[-.001,-.703]],2,6,["bez","csxy",[0,-.703]]],
> $fn=30)
> square(2.0, $fn=30);
>
> I'd like to know if it is possible to specify points and get a smooth bezier to
> include them.  I don't want to have the points off the path, but rather on the
> path that has a few points to define it.
>
> John
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves with smooth tangents at points

John Griessen
On 10/15/2013 05:30 AM, Ruud Vlaming wrote:
> Hi John,
>
let go of the idea that the edges are the 'long'
> part and vertices the 'short', there is really no
> need for that.

It doesn't help in the task I have though.  getting a smaller circle somewhere
inside a square is not what I was searching.  I want to have exact dimensions and then curve some
places between those some to be a nice millable shape.  Seems a common want in
making either 3DP or machinable shapes.

Most functions in OpenSCAD are defined by parameters that are the critical dimensions,
so making some part fit with others is easy, and that is how I am thinking here.
I'm only looking for functions like that -- with dimensions easily known by definition,
or somehow known at some points.  When using a tool like inkscape, with handles on bezier
segments, it is easy to change a curve while leaving the endpoint in place.
That would be great to have in OpenSCAD.

> Of course, you can define an edge using a bezier,
> and obtain a CD vertex, but then make sure that
> the imaginary line through the control points around
> the vertex crosses that vertex, like this:
>
>     loop(rect=[[8,6]], edges=[1,["bez",[7,-1]],2,["bez",[9,1]]], $fn=50);

What do all those parameters do?  I haven't a clue.
>
> The hard parts are these:
> (1) a line build using bezier points, does not cross
>       those points, so it is difficult to define a
>       particular trajectory.

Yes, that's what I see with bezier and also with arc  --  points are not on the path they define.
Does the CD vertex always end up floating away from a point?  Is there any function in loop()
that keeps a segment end point CD connected to the next one, and staying where it is defined as input?

> At this moment the loop function does not have the
> possibility to draw automatically a poly spline
> through a series of points. This can be added, but
> i doubt if it would be of great benefit. The problem
> is that the curve in between still has much degrees
> of freedom that have to be parametrized somehow,
> and can exhibit wild behavior. Besides that,
> exactly the same result can be achieved using
> bezier around all vertices.

Spline seems what i am wanting.

  If not,
> please post a (hand)drawing

http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-1.png

The cross hatched zone between two lines is the square loop_extrude() I have attempted.

>> I'd like to know if it is possible to specify points and get a smooth curve to
>> include them.  I don't want to have the points off the path, but rather on the
>> path that has a few points to define it.

Seems not possible still.  A set of bezier segments might approximate that, but would require a large
number of points, which reduces the value of it as a tool.  Beziers seem to work best
in a WYSIWYG setting like inkscape because there the handles/control points do not move the
curve away from its defining points. At least, not at the endpoints.

Here is one I tried, using polar coords, (polar is working nicely), but not getting
me much benefit in simplifying a mostly cylindric shape.
It looks less like the desired circle with indents than before with
bezier on edges:

loop_extrude(
points=["polar",[20,0],[25,15],[25,90],[25,165],[20,180],[25,195],[25,200],[25,250],[25,290],[25,345]],
vertices=[1,5,["arc",2.5],2,4,6,3,7,8,9,"bez",[2,2,0.5,0.5]],
$fn=40)
square(2.0, $fn=40);

screenshot of above:
http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt2.png

I don't know exactly how you mean the parameters for "bez", just guessing from basic bezier curve definitions.

When I change the parameters like this,

"bez",[9,9,0.5,0.5]
the curve passes through a point farther from the points in my list,
so that is not at all what I am looking for, even though it is smoother.
It's not a help to make a new shape out in
space somewhere that I would have to go measure and iterate to get it to fit with other parts.
I could use Blender like that.  (And the process would still be tedious).

Bezier curves on edges seemed closer to accomplishing that, but it's hard to guess the parameters to have
a smooth transition at the point where one edge stops and another starts.

On 10/15/2013 05:30 AM, Ruud Vlaming wrote:> At this moment the loop function does not have the
 > possibility to draw automatically a poly spline
 > through a series of points. This can be added, but
 > i doubt if it would be of great benefit.

I think any milling machine operators would value it highly -- it's a basic CAM function to have
radii of concave corners redefinable easily...  Convex also.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves with smooth tangents at points

John Griessen
In reply to this post by devlaam
On 10/15/2013 05:30 AM, Ruud Vlaming wrote:
> you can define an edge using a bezier,
> and obtain a CD vertex, but then make sure that
> the imaginary line through the control points around
> the vertex crosses that vertex, like this:
>
>     loop(rect=[[8,6]], edges=[1,["bez",[7,-1]],2,["bez",[9,1]]], $fn=50);

What do these parameters, (above), mean?
>
> The hard parts are these:
> (1) a line build using bezier points, does not cross
>       those points, so it is difficult to define a
>       particular trajectory.
> (2) If you want to use a relative coordinate system,
>       keeping the control points at the correct location
>       can be really difficult.

I think by (2) you mean polar coordinates I used.
Is your bezier implementation only for x y z coordinates?  Or is bezier
method Cartesian coordinates by definition?

I think bezier edges might give me something usable for an o-ring groove,
so I'm experimenting with that more.  The following example shows how
putting a vertex with rounding by "arc" adjacent to a bezier edge
yields an unwanted wrinkle where they join.  My aim of using some points exactly on a circle, then
using loop_extrude() to deviate from that perfect circle seems all guesses below.


http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt3.png

loop_extrude(
points=["polar",
[20,0],
[25,15],
[25,30],
[25,90],
[25,150],
[25,165],
[20,180],
[25,195],
[25,205],
[25,250],
[25,290],
[25,335],
[25,345],
],
vertices=[
1,2,6,7,8,13,["arc",2.5],
3,5,["arc",2.0],
],
edges=[
// 8,["bez",[2,2,-0.5,-0.5]],
3,4,["bez","csxy",[0.001,-.641]],
],
$fn=40)
square(2.0, $fn=40);

Here's one using only "bez"  some on vertices, some on edges. The joins between them
have discontinuities though.  I don't understand the parameter list for "bez",
and can't find it out from the docs.  Time to start reading the code, I guess.

http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt4.png

loop_extrude(
points=["polar",
[17,0],
[25,09],
[25,25],
[25,90],
[25,150],
[25,165],
[20,180],
[25,195],
[25,205],
[25,250],
[25,290],
[25,335],
[25,345],
],
vertices=[
6,7,8,13,["arc",2.1],
// 3,5,["arc",2.0],
1, 2,["bez",3.6,3.6,0.3,0.3]
],
edges=[
// 8,["bez",[2,2,0.5,0.5]],
3,4,["bez","csxy",[0.001,-.631]],
],
$fn=40)
square(2.0, $fn=40);

John Griessen
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves with smooth tangents at points

John Griessen
In reply to this post by devlaam
On 10/15/2013 05:30 AM, Ruud Vlaming wrote:
> Hi John,
>
.
.
.
> The hard parts are these:
> (1) a line build using bezier points, does not cross
>       those points, so it is difficult to define a
>       particular trajectory.

I looked back at some of the Bezier curve definitions and it seems defined like
I remember in inkscape and Photoshop.  The end points do not move as control points change.

 From http://cagd.cs.byu.edu/~557/text/ch2.pdf  Ch. 2 Bezier curves

"The beauty of the
Bezier representation is that a Bezier curve mimics the shape of its control polygon. A Bezier
curve passes through its first and last control points, and is tangent to the control polygon at those
endpoints."

So, have you implemented bezier, or something else?  It might be you're making a bezier
curve that starts at the "cutoff" line segment endpoints...  which is stopping
me from finding a way to use it for the CAD "radius corners" function.

I have not been able to deduce the parameter meanings enough to help debug.
I took a look at loop.cc and don't understand much there yet either.
  if (Lib::has<std::string>(strs,"bez")) { return Edge::BEZ; }
from the code suggests the CGAL lib has most of the bezier function in it...

Maybe if I understood the parameters I could use inkscape as a step in a process,
and edit the svg file directly to change some mouse created numbers to exact
dimensions.  I could force it to be a CAD tool maybe.  Once I had points with bezier curves
for the circular sections and straight lines, I might be able to add a bezier curve to fill the gap smoothly.

John Griessen


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves with smooth tangents at points

devlaam
In reply to this post by John Griessen
On 15-10-13 23:18, John Griessen wrote:

> Most functions in OpenSCAD are defined by parameters that are the critical dimensions,
> so making some part fit with others is easy, and that is how I am thinking here.
> I'm only looking for functions like that -- with dimensions easily known by definition,
> or somehow known at some points.  When using a tool like inkscape, with handles on bezier
> segments, it is easy to change a curve while leaving the endpoint in place.
> That would be great to have in OpenSCAD.
Be careful what you wish for :) If you need a the vertex situated
at a predefined point, and continuously differentiable, you
have to bend the edges, there is no way around that. So i choose
for vertex implementation where you cut of some length of both
sides (seen from the vertex point) and reconnect the endpoints
by an arc or spline (third order bezier). In this way you always
have CD at the joining points, but the price you pay is that
the vertex is not situated at the original point any more.



>> Of course, you can define an edge using a bezier,
>> and obtain a CD vertex, but then make sure that
>> the imaginary line through the control points around
>> the vertex crosses that vertex, like this:
>>
>>      loop(rect=[[8,6]], edges=[1,["bez",[7,-1]],2,["bez",[9,1]]], $fn=50);
>
> What do all those parameters do?  I haven't a clue.

This is the other solution. It keeps the vertex at its predefined
location, but now you have to deform the edge. In this example, we
added one bezier control point the edges. In edge 1, the point
is located at x=7, y=-1 and in edge 2 it is at x=9, y=1.
The rect=[[8,6]] simply draws an rectangle with sides 8 and 6.
Because the line through [7,-1] and [9,1] also crosses
the vertex of the rectangle at [8,0] the line is CD at
this vertex.

>> At this moment the loop function does not have the
>> possibility to draw automatically a poly spline
>> through a series of points. This can be added, but
>> i doubt if it would be of great benefit. The problem
>> is that the curve in between still has much degrees
>> of freedom that have to be parametrized somehow,
>> and can exhibit wild behavior. Besides that,
>> exactly the same result can be achieved using
>> bezier around all vertices.
>
> Spline seems what i am wanting.
Spline is a third order bezier, so nothing to add here.

>
>    If not,>> please post a (hand)drawing
>
> http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-1.png
OK, it is a sketch, but does not include the model
parameters. In other words, what are predefined shapes
and what parameters do you want to control. If i know
that, i can write a module. Please keep it reasonable,
i do want to help, but not invest two days drawing.

> Seems not possible still.  A set of bezier segments might approximate that, but would require a large
> number of points, which reduces the value of it as a tool.  Beziers seem to work best
> in a WYSIWYG setting like inkscape because there the handles/control points do not move the
> curve away from its defining points. At least, not at the endpoints.
Endpoints of bezier are part of the curve, the problem
lies in between. I could write and add functionality that
constructs splines between given points, but that would
give rise to uncontrolled line pieces in between.


> Here is one I tried, using polar coords, (polar is working nicely), but not getting
> me much benefit in simplifying a mostly cylindric shape.
> It looks less like the desired circle with indents than before with
> bezier on edges:
>
> loop_extrude(
> points=["polar",[20,0],[25,15],[25,90],[25,165],[20,180],[25,195],[25,200],[25,250],[25,290],[25,345]],
> vertices=[1,5,["arc",2.5],2,4,6,3,7,8,9,"bez",[2,2,0.5,0.5]],
> $fn=40)
> square(2.0, $fn=40);
>
> screenshot of above:
> http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt2.png
Okay, but
>
> I don't know exactly how you mean the parameters for "bez",
> just guessing from basic bezier curve definitions.
Did you have a look in my manual. It is explained there (although
very terse. For bez in the vertex def, the first two parameters
are the cut-off lengths, the second two determine how far the
(two) control points are situated from the cut-off point. They
are always situated on the imaginary line trough the tangent
op the cut-off point. That ensures CD at that point.

"bez" on the edge definition simply defines control
points, which can be positioned at free will.


> When I change the parameters like this,
>
> "bez",[9,9,0.5,0.5]
9: cutoff length left edge (as seen from vertex)
9: cutoff length right edge  (as seen from vertex)
0.5 put the control point exactly between cut-off and original vertex.
0.5: idem

Ruud.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves with smooth tangents at points

devlaam
In reply to this post by John Griessen
On 16-10-13 17:44, John Griessen wrote:

>>      loop(rect=[[8,6]], edges=[1,["bez",[7,-1]],2,["bez",[9,1]]], $fn=50);
>
> What do these parameters, (above), mean?
See previous post.

>> The hard parts are these:
>> (2) If you want to use a relative coordinate system,
>>        keeping the control points at the correct location
>>        can be really difficult.
>
> I think by (2) you mean polar coordinates I used.
Yep, and for relative systems as well.

> Is your bezier implementation only for x y z coordinates?  Or is bezier
> method Cartesian coordinates by definition?
There you have a point. In Bez you can only specify cartesian
coordinates. They may be relative, when using csxy or so, but
cannot (yet) be absolute polar. I have to think about that.

> http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt3.png
> http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt4.png

Thanks for these examples. As soon as have some
more time, i will give it a try myself. I have
the feeling you make it to difficult. Is seems
to me that at least the large part can be a
single edge.

 > Here's one using only "bez"  some on vertices, some on
 > edges. The joins between them have discontinuities though.
 > I don't understand the parameter list for "bez",
 > and can't find it out from the docs.  Time to start
 > reading the code, I guess.

I don't think reading code will bring you a lot further,
unless you are well trained in C++ and math. I would
say look and try (retype, do not copy paste, may
not work due to invisible characters in the pdf)
the examples from page 8 and 9
from my manual.

Ruud


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves with smooth tangents at points

devlaam
In reply to this post by John Griessen
On 17-10-13 00:47, John Griessen wrote:
> So, have you implemented bezier, or something else?  It might be you're making a bezier
> curve that starts at the "cutoff" line segment endpoints...  which is stopping
> me from finding a way to use it for the CAD "radius corners" function.
I have implemented full bezier for the edges and cubic bezier (spline,
two control points, situated at the tangent of the cut-off points)
for the vertices.

> I have not been able to deduce the parameter meanings enough to help debug.
> I took a look at loop.cc and don't understand much there yet either.
>    if (Lib::has<std::string>(strs,"bez")) { return Edge::BEZ; }
> from the code suggests the CGAL lib has most of the bezier function in it...
Eh ... CGAL bezier?  I do not use that and cannot follow you at this point.

> Maybe if I understood the parameters
I hope i explained them clearly enough in the previous post.

Ruud.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

John Griessen
On 10/17/2013 03:27 AM, Ruud Vlaming wrote:
> I have implemented full bezier for the edges and cubic bezier (spline,
> two control points, situated at the tangent of the cut-off points)
> for the vertices.

I will try making some simplest possible test cases for vertices.
It would really be helpful to have another type of vertex
that does not move, has direction of control points on a line
that is tangent at the vertex, and 2 control parameters are:
forward direction of path control point distance relative to vertex,
backward direction of path control point distance relative to vertex.
The above would involve two segments, so maybe that is difficult,
but that is what would be helpful for a "CAM function to have radii
of concave or convex corners redefinable easily".


Edges using x-y parameters requires "by hand" inputs, so not simplifying enough.
My attempts put numbers in after defining points in polar coords, so the control
points were always off in some undesired direction.

Vertices allowing a control point that is on the tangent is just what I want.
Only I want

On 10/17/2013 03:10 AM, Ruud Vlaming wrote:> It is explained there (although
 > very terse. For bez in the vertex def, the first two parameters
 > are the cut-off lengths, the second two determine how far the
 > (two) control points are situated from the cut-off point. They
 > are always situated on the imaginary line trough the tangent
 > of the cut-off point. That ensures CD at that point.

Thanks for this more complete parameter definition!
Can the first two be zero?  Probably.  I'll see what I
can draw with that.  If that is allowed by your code,
I think I have discovered what I wanted.

John Griessen
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

John Griessen
In reply to this post by devlaam
On 10/17/2013 03:27 AM, Ruud Vlaming wrote:
> I have implemented full bezier for the edges and cubic bezier (spline,
> two control points, situated at the tangent of the cut-off points)
> for the vertices.

I will try making some simplest possible test cases for vertices.

<img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-1.png" alt="curve sketch">
<img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png" alt="curve sketch">

On 10/17/2013 03:10 AM, Ruud Vlaming wrote:> It is explained there (although
  > very terse. For bez in the vertex def, the first two parameters
  > are the cut-off lengths, the second two determine how far the
  > (two) control points are situated from the cut-off point. They
  > are always situated on the imaginary line trough the tangent
  > of the cut-off point. That ensures CD at that point.

Thanks for this more complete parameter definition!
Can the first two be zero?

It seems not.  Zero just makes abrupt discontinuities.

Here's my code for a try at points defining curves
that go through the points:

loop_extrude(
points=["polar",
[25,0],
[25,60],
[25,120],
[25,160],
[25,165],
[20,175],
[20,185],
[25,195],
[25,200],
[25,240],
[25,300],
],
vertices=[
1, 2,3,9,["bez",0,0,1.3,1.3]
],
edges=[
1,["bez",[0.5,0.5]],
],
$fn=40)
square(2.0, $fn=40);

// 3,5,["arc",2.0],
//3,4,["bez","csxy",[0.001,-.631]],

<img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt5.png" alt="attempt5.png">

John Griessen
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

John Griessen
In reply to this post by devlaam
Here's my code for another try at points defining curves
that go through the points.  bezier edges can be made sort of smooth
transition to other edges of same radius of curvature, but tight bends just
square off.  Vertices always change points to get their
effect -- maybe I'll try a work around using those later.

I'm new at C++, but have done numerical programming math.  I might
be able to make use of some hints about the code.

loop_extrude(
points=["polar",
[25,0],
[25,60],
[25,120],
[25,160],
[25,165],
[20,175],
[20,185],
[25,195],
[25,200],
[25,240],
[25,300],
],
vertices=[
// 3,4,5,6,7,8,9,["bez",-2,-2,3.3,3.3],
// 1,2,["bez",-4,-4,3.3,3.3],
],
edges=[
1,2,["bez","csxy",[0.001,-.531]],
3,["bez","csxy",[0.001,-.331]],
4,5,["bez","csxy",[0.001,-.131]],
6,7,["bez","csxy",[0.001,-.331]],
8,9,["bez","csxy",[0.001,-.331]],
],
$fn=40)
square(2.0, $fn=40);

// 3,5,["arc",2.0],
// 1,["bez",10,10,1.5,1.5],

http://ecosensory.com/bitmaps/openscad-tangent-curves-attempt6.png

John Griessen
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

devlaam
In reply to this post by John Griessen
On 17-10-13 16:57, John Griessen wrote:
> It would really be helpful to have another type of vertex
> that does not move, has direction of control points on a line
> that is tangent at the vertex, and 2 control parameters are:
> forward direction of path control point distance relative to vertex,
> backward direction of path control point distance relative to vertex.
> The above would involve two segments, so maybe that is difficult,
> but that is what would be helpful for a "CAM function to have radii
> of concave or convex corners redefinable easily".
I can understand the wish, but at the moment i have no
plans to extend the functionality. First, this has to be
integrated into the main branch (i.e. must become part
of the regular program), and second, we must collect more
user experiences.


> Can the first two be zero?  Probably.  I'll see what I
> can draw with that.
Yes, but it would make no sense, since the vertex is not
modified then, you can just as well leave the modification
out.

Ruud

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

devlaam
In reply to this post by John Griessen
On 17-10-13 18:25, John Griessen wrote:
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-1.png"  alt="curve sketch">
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png"  alt="curve sketch">

Okay i will give this a try tomorrow.
Ruud

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

Peter Falke
I was wondering for a while if there is a way to do a negative_hull() like this:
(please excuse the crummy picture, Paint is all I had :-) )

Sincerely,

TakeItAndRun
Inline-Bild 1


2013/10/17 Ruud Vlaming <[hidden email]>
On 17-10-13 18:25, John Griessen wrote:
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-1.png"  alt="curve sketch">
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png"  alt="curve sketch">

Okay i will give this a try tomorrow.
Ruud

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

nophead
Yes that would be very useful, I often want to do it, but hull() is only convex.


On 18 October 2013 20:10, Peter Falke <[hidden email]> wrote:
I was wondering for a while if there is a way to do a negative_hull() like this:
(please excuse the crummy picture, Paint is all I had :-) )

Sincerely,

TakeItAndRun
Inline-Bild 1


2013/10/17 Ruud Vlaming <[hidden email]>
On 17-10-13 18:25, John Griessen wrote:
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-1.png"  alt="curve sketch">
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png"  alt="curve sketch">

Okay i will give this a try tomorrow.
Ruud

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

John Griessen
On 10/18/2013 03:01 PM, nop head wrote:
> Yes that would be very useful, I often want to do it, but hull() is only convex.
+1
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

Whosawhatsis
In reply to this post by nophead
+1

Would LOVE to have that, though specifying how it should work in a non-ambigious way is tricky.

On Friday, October 18, 2013 at 1:01 PM, nop head wrote:

Yes that would be very useful, I often want to do it, but hull() is only convex.


On 18 October 2013 20:10, Peter Falke <[hidden email]> wrote:
I was wondering for a while if there is a way to do a negative_hull() like this:
(please excuse the crummy picture, Paint is all I had :-) )

Sincerely,

TakeItAndRun
Inline-Bild 1


2013/10/17 Ruud Vlaming <[hidden email]>
On 17-10-13 18:25, John Griessen wrote:
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-1.png"  alt="curve sketch">
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png"  alt="curve sketch">

Okay i will give this a try tomorrow.
Ruud

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

devlaam
In reply to this post by John Griessen
On 17-10-13 18:25, John Griessen wrote:
> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png" alt="curve sketch">

I assume you want to prescribe the points 1..9? In my view
i would rather parametrize using curvatures R,r and the
angle of opening. Seems more natural to me.

Some questions:
- Are the points 1,2,3,4,9 supposed to be on a circle?
- Can i simply minimize the curvature in when drawing a
   'freeform' line through 4,5,6,7,8,9?

Ruud.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

John Griessen
On 10/19/2013 10:55 AM, Ruud Vlaming wrote:
> On 17-10-13 18:25, John Griessen wrote:
>> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png" alt="curve sketch">
>
> I assume you want to prescribe the points 1..9?

Yes.  Those points are to be on a path.  2 and 3 could be left out and define 1,4,9
to be on a circle.  Curves in between
would be adjustable so they fit between inner and outer cylinder shapes
to make an o-ring gasket groove on the end of a pipe like cylinder shape.

In my view
> i would rather parametrize using curvatures R,r and the
> angle of opening. Seems more natural to me.

That could solve my original design intent, but not be as general
as defining by points.

I was able to get one smooth curve using "arc" that way with few points,
but it would not satisfy the design, since I hit limits of your code working
with some dimensions -- "cutoffs won't fit" warning.  Example of this at end of this email.

If the scale of points defining a loop is changed from a radius of 25
to 250 will any of those limits for tight curves go away?

The curvatures between points
4,5
6,7
8,9
could all be approx r1, but curvature between points
5,6
7,8
would be approx r2.
R might be curvature between circle points
1,2
2,3
9,1

of the loop.

>
> Some questions:
> - Are the points 1,2,3,4,9 supposed to be on a circle?

Yes.

> - Can i simply minimize the curvature in when drawing a
>     'freeform' line through 4,5,6,7,8,9?

As in keep radius of curvature as large as possible?  Yes.

A way to do that for arbitrary points would be fabulous.  Where you wanted the path
to follow constraints, put more points, else let it curve.  With that
built in goal of "keep radius of curvature large", one would not even need to
fiddle with control points, just define different point locations to discover
what radii result.

If you had a practical constraint like a milling cutter size, it would be nice to be able to
specify the tightest radius allowable and error out
if points were chosen so close that could not be done.

Are you thinking there's a way to program such with your loop code as is, or
new code required?

John

The below code renders like this, with flats, (non-continuous between "arc" vertex and "bez" segment.

http://ecosensory.com/bitmaps/o-ring-toolpath-arcs.scad.png

loop_extrude(
points=["polar",
[25,0],
[25,09],
[25,25],
[25,90],
[25,150],
[25,165],
[20,180],
[25,195],
[25,205],
[25,250],
[25,290],
[25,335],
[25,345],
],
vertices=[
6,7,8,13,["arc",2.1],
// 3,5,["arc",2.0],
1, 2,["bez",3.6,3.6,0.3,0.3]
],
edges=[
// 8,["bez",[2,2,0.5,0.5]],
3,4,["bez","csxy",[0.001,-.631]],
],
$fn=40)
square(2.0, $fn=40);
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: loop_extrude() to get curves continuously differentiable at points

devlaam
Hi John,

Based on what you drawn, i made this:

loop_extrude(
  points=["polar",[20,0],[25,15],[25,30],[25,90],
    [25,150],[25,165],[20,180],[25,195],[25,210],
    [25,270],[25,330],[25,345]],
  vertices=[1,2,6,7,8,12,["arc",2.1]],
  edges=[3,4,9,10,["bez","csxy",[0.001,-.631]]],$fn=40)
    square(2.0);

I understand that is not you are looking for, but it is the
best i can do given the available time. The biggest problem
is (i think) that a bezier can never replace an arc, and
you cannot choose arc for the edge.

Your general request, that is draw a 'smooth' curve through a
series of points, and maybe let me specify what 'smooth' is
through some extra parameters, is not possible with the
present code. Can this be added? Sure, but i am not
certain if it fit the drawing model presently used.
That is ( for loop() ):
  - specify a series of points that form a polygon.
  - be able do cut of some of the edges around the
    vertices and draw something 'nice' in between
    (usual for rounding of edges). With this action
    two new fixed points arise around each vertex.
  - be able to replace the line connecting the fixed
    points using piecewise linear line pieces or a
    multipoint Bezier curve.    

I understand your wish, and you demonstrated there is
a use case for this. My use case was, i have a piece
of material that i want to bend and round of its
corners. Bezier on the edges was a little something
extra that i myself did not really need.

Btw, if you design an extruded object, it is usually
better for first make sure the loop() is correct and
that change it loop_extrude() with some other object.
That makes it easier to solve any design errors.

On of which is:
> If the scale of points defining a loop is changed from a
> radius of 25 to 250 will any of those limits for tight
> curves go away?
This came up because you cut off more length from a side
than is available. You must increase the side length or
reduce the cuf-off. With polar coordinates it is hard to
predict how long the sides are (well not that hard,
but ...)

I understand this answer is not satisfactory for you
but it is the best i can do, please excuse me for that.

Have fun.
Ruud


On 20-10-13 00:34, John Griessen wrote:

> On 10/19/2013 10:55 AM, Ruud Vlaming wrote:
>> On 17-10-13 18:25, John Griessen wrote:
>>> <img src="http://ecosensory.com/bitmaps/openscad-tangent-curves-sketch-simplest-2.png" alt="curve sketch">
>>
>> I assume you want to prescribe the points 1..9?
>
> Yes.  Those points are to be on a path.  2 and 3 could be left out and define 1,4,9
> to be on a circle.  Curves in between
> would be adjustable so they fit between inner and outer cylinder shapes
> to make an o-ring gasket groove on the end of a pipe like cylinder shape.
>
> In my view
>> i would rather parametrize using curvatures R,r and the
>> angle of opening. Seems more natural to me.
>
> That could solve my original design intent, but not be as general
> as defining by points.
>
> I was able to get one smooth curve using "arc" that way with few points,
> but it would not satisfy the design, since I hit limits of your code working
> with some dimensions -- "cutoffs won't fit" warning.  Example of this at end of this email.
>
> If the scale of points defining a loop is changed from a radius of 25
> to 250 will any of those limits for tight curves go away?
>
> The curvatures between points
> 4,5
> 6,7
> 8,9
> could all be approx r1, but curvature between points
> 5,6
> 7,8
> would be approx r2.
> R might be curvature between circle points
> 1,2
> 2,3
> 9,1
>
> of the loop.
>
>>
>> Some questions:
>> - Are the points 1,2,3,4,9 supposed to be on a circle?
>
> Yes.
>
>> - Can i simply minimize the curvature in when drawing a
>>      'freeform' line through 4,5,6,7,8,9?
>
> As in keep radius of curvature as large as possible?  Yes.
>
> A way to do that for arbitrary points would be fabulous.  Where you wanted the path
> to follow constraints, put more points, else let it curve.  With that
> built in goal of "keep radius of curvature large", one would not even need to
> fiddle with control points, just define different point locations to discover
> what radii result.
>
> If you had a practical constraint like a milling cutter size, it would be nice to be able to
> specify the tightest radius allowable and error out
> if points were chosen so close that could not be done.
>
> Are you thinking there's a way to program such with your loop code as is, or
> new code required?
>
> John
>
> The below code renders like this, with flats, (non-continuous between "arc" vertex and "bez" segment.
>
> http://ecosensory.com/bitmaps/o-ring-toolpath-arcs.scad.png
>
> loop_extrude(
> points=["polar",
> [25,0],
> [25,09],
> [25,25],
> [25,90],
> [25,150],
> [25,165],
> [20,180],
> [25,195],
> [25,205],
> [25,250],
> [25,290],
> [25,335],
> [25,345],
> ],
> vertices=[
> 6,7,8,13,["arc",2.1],
> // 3,5,["arc",2.0],
> 1, 2,["bez",3.6,3.6,0.3,0.3]
> ],
> edges=[
> // 8,["bez",[2,2,0.5,0.5]],
> 3,4,["bez","csxy",[0.001,-.631]],
> ],
> $fn=40)
> square(2.0, $fn=40);
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
12