discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Where is "path_pos_from_start" in BOLS2 ?

AM
Adrian Mariano
Wed, Oct 12, 2022 8:46 PM

I have run your code and I have read it through, and as I have said many
times it appears WRONG.  Whether I am right about that depends on the exact
meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean exactly?
I think the reason you don't end where you expect is probably that you
divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item is
placed at length L from the end of your model?  Or is the intent that the
item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are treating
pb as a curve in 2d.  But from reading your code, it appears that pb is NOT
a curve in 2d.  It is a lookup table that specifies the diameter as a
function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives diameter
then the correct diameter at the midpoint, position 1, is 5, but if you use
the method implemented in the neck1000 code which is based on path length,
so path_pos_from_start(p,path_length(p)/2) you get a diameter of 0.47
instead of 5.  You can't assume that the functions will magically produce
the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for generating
tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors compiling is
fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200 code.
There is a list of points in 2d described as "diameter".  It appears that
maybe the second value is the position and the first value the diameter at
that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of cylinders.  I
would do this with sweep.  I would use path_sweep with the transforms=true
option to get a list of transform matrices.  I would apply the scales to
those and then invoke sweep().

For putting objects on the surface you should be able to do it with just a
call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two curve
approach.
One curve is path to "extrude" and second is - diameters along this path.
After bulding tube I place toneholes, posts and etc, defined by length
from top of tube.
So I need function to return diameter at given length and angle to rotate
item I want to place
I draw curve manually in MOI3D then save as polyline dxf then convert to
openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more elegant
solution.

Equal spacing along the curve is overkill on straight segments. BSpline
examples in this maillist seems to be useful but I didnot realize how to
implement.
I still didnot understand why length of the resulting tube depends from
quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was redundant
with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place an item
on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I have run your code and I have read it through, and as I have said many times it appears WRONG. Whether I am right about that depends on the exact meaning of pb. p = [[0,0],[1,5],[2,100]]; echo(path_pos_from_start(p,path_length(p)/2)); echo(lookup(1,p)); The output is ECHO: [1, 0.473165] ECHO: 5 So please tell me the intention. What do the entries in pb mean exactly? I think the reason you don't end where you expect is probably that you divided by n instead of n+1 in the loop. When you use the command place_item(L) is the intention that the item is placed at length L from the end of your model? Or is the intent that the item is placed somewhere else, approximately L but not exactly L? Your existing code does the second thing, not the first one. On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < discuss@lists.openscad.org> wrote: > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin <yur_vol@yahoo.com> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) > Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? > I tried your idea but don't get 0.47. It still seems linear > interpolatetion here. > Please run my code with old paths.scad I attached. It's working code. > > * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian Mariano > <avm4@cornell.edu <avm4@cornell.edu>> wrote: * > > > *When you invoke path_pos_from_start() on the pb variable you are treating > pb as a curve in 2d. But from reading your code, it appears that pb is NOT > a curve in 2d. It is a lookup table that specifies the diameter as a > function of path length along the curve defined by p. I am somewhat > guessing here based on the code, but if that is true, then treating it like > a curve in 2D will give incorrect results. If we have a simple example:* > > > *p=* > *[[0,0],* > * [1,5],* > * [2,100]]* > > *where the first entry gives position and the second entry gives diameter > then the correct diameter at the midpoint, position 1, is 5, but if you use > the method implemented in the neck1000 code which is based on path length, > so path_pos_from_start(p,path_length(p)/2) you get a diameter of 0.47 > instead of 5. You can't assume that the functions will magically produce > the right answer even if you ask them to do the wrong thing!* > > *Interpolating a 2d curve, which is what path_pos_from_start (and > path_cut) do is not the same as interpolating a lookup table. A correct > way to get that value would be lookup(1,p); I think you can replace every > call of path_pos_from_start with lookup and then you won't need the old > function. * > > On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < > discuss@lists.openscad.org> wrote: > > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin <yur_vol@yahoo.com> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) > Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? > As I understand interpolation is done automatically inside the BOLS2 > functions. Dont know what exactly method is implemented. > You set number of equally spaced interpolation points only for generating > tube. It does not depend from how input path set. > So you can find a point at given length. > For tangent/normal rotating items I set rotate_children=true > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < > avm4@cornell.edu> wrote: > > > I examined neck1200.scad. The problem reported about errors compiling is > fixed by removing the "use" statements. > > However, I'm a little confused about the intent of the neck1200 code. > There is a list of points in 2d described as "diameter". It appears that > maybe the second value is the position and the first value the diameter at > that position. This point list is then operated on using > path_pos_from_start. But that doesn't make sense, because the data is not > actually a path in 2d. You should be interpolating just on the second > coordinate to find position. I would probably do this with lookup()----but > the coordinates would need to be swapped first. > > The code for creating the actual shape is a chain hull of cylinders. I > would do this with sweep. I would use path_sweep with the transforms=true > option to get a list of transform matrices. I would apply the scales to > those and then invoke sweep(). > > For putting objects on the surface you should be able to do it with just a > call to path_spread(), I think. Note that path_cut is not a drop in > replacement for path_pos_from_start(). The old function returned an index > into the path plus a fraction along the next path segment. The new > function takes a list of cut points and returns all the paths cut at those > points, so you can then extract the ends that you need directly. > > Docs for path_cut: > https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut > > If you just want the code to work, here's the old function: > > function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = > let (lp = len(path)) > _i >= lp - (closed?0:1)? undef : > let (l = norm(path[(_i+1)%lp]-path[_i])) > _d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) : > [_i, (length-_d)/l]; > > On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < > discuss@lists.openscad.org> wrote: > > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin <yur_vol@yahoo.com> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) > Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? > Direct replacement does not work. see attachment > > More info: > To reverse engineering saxophones for fdm 3dprinting I use two curve > approach. > One curve is path to "extrude" and second is - diameters along this path. > After bulding tube I place toneholes, posts and etc, defined by length > from top of tube. > So I need function to return diameter at given length and angle to rotate > item I want to place > I draw curve manually in MOI3D then save as polyline dxf then convert to > openscad polyline with dxfwread.exe tool. > I almost solved all the above, but have a feel that there is more elegant > solution. > > Equal spacing along the curve is overkill on straight segments. BSpline > examples in this maillist seems to be useful but I didnot realize how to > implement. > I still didnot understand why length of the resulting tube depends from > quantization number and how to avoid its changing. > > > > > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < > avm4@cornell.edu> wrote: > > > I believe that path_pos_from_start was eliminated because it was redundant > with path_cut. Can path_cut do what you need? > > On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < > discuss@lists.openscad.org> wrote: > > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin <yur_vol@yahoo.com> > To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) > Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? > I use this function in BOLS2 from 2020 for finding point to place an item > on curved tube. > It is absent in newer BOLS2. > What I need to use insteed ? > > SY, Yuri > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> > To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> > Cc: Mr Yura Volodin <yur_vol@yahoo.com> > Bcc: > Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) > Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: Mr Yura Volodin <yur_vol@yahoo.com> > Bcc: > Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) > Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: Mr Yura Volodin <yur_vol@yahoo.com> > Bcc: > Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) > Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > ---------- Forwarded message ---------- > From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> > To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> > Cc: Mr Yura Volodin <yur_vol@yahoo.com> > Bcc: > Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) > Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Wed, Oct 12, 2022 10:40 PM

So actually when I said n+1 it should have been n-1.  When I wrote the
replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1] );
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],    diam[1]);
hull(){
path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at i*bl/n
whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).  That
means that you will omit the last sample.  It seems odd, but I was just
duplicating the functionality of your code.  As I have said, there are many
things that look strange, but only you can say if they are in fact wrong.
It does seem like in most places, the incorrect looking code only makes a
small difference in the outcome, like things shift around by less than 1
unit.

If you want to duplicate the current functionality I still think path_cut
is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend on the
obsolete function.  Also attached is a version that uses sweep() the way I
would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu wrote:

I have run your code and I have read it through, and as I have said many
times it appears WRONG.  Whether I am right about that depends on the exact
meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item is
placed at length L from the end of your model?  Or is the intent that the
item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives diameter
then the correct diameter at the midpoint, position 1, is 5, but if you use
the method implemented in the neck1000 code which is based on path length,
so path_pos_from_start(p,path_length(p)/2) you get a diameter of 0.47
instead of 5.  You can't assume that the functions will magically produce
the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for generating
tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors compiling is
fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200 code.
There is a list of points in 2d described as "diameter".  It appears that
maybe the second value is the position and the first value the diameter at
that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of cylinders.  I
would do this with sweep.  I would use path_sweep with the transforms=true
option to get a list of transform matrices.  I would apply the scales to
those and then invoke sweep().

For putting objects on the surface you should be able to do it with just
a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two curve
approach.
One curve is path to "extrude" and second is - diameters along this path.
After bulding tube I place toneholes, posts and etc, defined by length
from top of tube.
So I need function to return diameter at given length and angle to rotate
item I want to place
I draw curve manually in MOI3D then save as polyline dxf then convert to
openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more elegant
solution.

Equal spacing along the curve is overkill on straight segments. BSpline
examples in this maillist seems to be useful but I didnot realize how to
implement.
I still didnot understand why length of the resulting tube depends from
quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place an
item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

So actually when I said n+1 it should have been n-1. When I wrote the replacement code I followed your code. In your code you have this loop: for (i=[1:1:n-1]){ diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); diam = path_pos_from_start(pb,i*bl/n,closed=false); bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] ); bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], diam[1]); hull(){ path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); } } The max value of i is n-1. When you calculate diam you do it at i*bl/n whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). That means that you will omit the last sample. It seems odd, but I was just duplicating the functionality of your code. As I have said, there are many things that look strange, but only you can say if they are in fact wrong. It does seem like in most places, the incorrect looking code only makes a small difference in the outcome, like things shift around by less than 1 unit. If you want to duplicate the current functionality I still think path_cut is the best way to do it: module place_item_on_skin(l,angle){ pathlist = path_cut(pb,l,closed=false); pt = last(pathlist[0]); echo(equal=pt[1],pl-l); color("lightblue") path_spread(p, 1,1,pt[1]) rotate([90,0,0])translate([0,0,pt[0]/2])children(0); } Attached is a modified version of neck1200.scad that doesn't depend on the obsolete function. Also attached is a version that uses sweep() the way I would have coded this model. On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> wrote: > I have run your code and I have read it through, and as I have said many > times it appears WRONG. Whether I am right about that depends on the exact > meaning of pb. > > p = [[0,0],[1,5],[2,100]]; > echo(path_pos_from_start(p,path_length(p)/2)); > echo(lookup(1,p)); > > The output is > > ECHO: [1, 0.473165] > ECHO: 5 > > So please tell me the intention. What do the entries in pb mean > exactly? I think the reason you don't end where you expect is probably > that you divided by n instead of n+1 in the loop. > > When you use the command place_item(L) is the intention that the item is > placed at length L from the end of your model? Or is the intent that the > item is placed somewhere else, approximately L but not exactly L? Your > existing code does the second thing, not the first one. > > > > > > > On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < > discuss@lists.openscad.org> wrote: > >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin <yur_vol@yahoo.com> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: >> Bcc: >> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >> I tried your idea but don't get 0.47. It still seems linear >> interpolatetion here. >> Please run my code with old paths.scad I attached. It's working code. >> >> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian Mariano >> <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >> >> >> *When you invoke path_pos_from_start() on the pb variable you are >> treating pb as a curve in 2d. But from reading your code, it appears that >> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >> as a function of path length along the curve defined by p. I am somewhat >> guessing here based on the code, but if that is true, then treating it like >> a curve in 2D will give incorrect results. If we have a simple example:* >> >> >> *p=* >> *[[0,0],* >> * [1,5],* >> * [2,100]]* >> >> *where the first entry gives position and the second entry gives diameter >> then the correct diameter at the midpoint, position 1, is 5, but if you use >> the method implemented in the neck1000 code which is based on path length, >> so path_pos_from_start(p,path_length(p)/2) you get a diameter of 0.47 >> instead of 5. You can't assume that the functions will magically produce >> the right answer even if you ask them to do the wrong thing!* >> >> *Interpolating a 2d curve, which is what path_pos_from_start (and >> path_cut) do is not the same as interpolating a lookup table. A correct >> way to get that value would be lookup(1,p); I think you can replace every >> call of path_pos_from_start with lookup and then you won't need the old >> function. * >> >> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >> discuss@lists.openscad.org> wrote: >> >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin <yur_vol@yahoo.com> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: >> Bcc: >> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >> As I understand interpolation is done automatically inside the BOLS2 >> functions. Dont know what exactly method is implemented. >> You set number of equally spaced interpolation points only for generating >> tube. It does not depend from how input path set. >> So you can find a point at given length. >> For tangent/normal rotating items I set rotate_children=true >> >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < >> avm4@cornell.edu> wrote: >> >> >> I examined neck1200.scad. The problem reported about errors compiling is >> fixed by removing the "use" statements. >> >> However, I'm a little confused about the intent of the neck1200 code. >> There is a list of points in 2d described as "diameter". It appears that >> maybe the second value is the position and the first value the diameter at >> that position. This point list is then operated on using >> path_pos_from_start. But that doesn't make sense, because the data is not >> actually a path in 2d. You should be interpolating just on the second >> coordinate to find position. I would probably do this with lookup()----but >> the coordinates would need to be swapped first. >> >> The code for creating the actual shape is a chain hull of cylinders. I >> would do this with sweep. I would use path_sweep with the transforms=true >> option to get a list of transform matrices. I would apply the scales to >> those and then invoke sweep(). >> >> For putting objects on the surface you should be able to do it with just >> a call to path_spread(), I think. Note that path_cut is not a drop in >> replacement for path_pos_from_start(). The old function returned an index >> into the path plus a fraction along the next path segment. The new >> function takes a list of cut points and returns all the paths cut at those >> points, so you can then extract the ends that you need directly. >> >> Docs for path_cut: >> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >> >> If you just want the code to work, here's the old function: >> >> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >> let (lp = len(path)) >> _i >= lp - (closed?0:1)? undef : >> let (l = norm(path[(_i+1)%lp]-path[_i])) >> _d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) : >> [_i, (length-_d)/l]; >> >> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >> discuss@lists.openscad.org> wrote: >> >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin <yur_vol@yahoo.com> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: >> Bcc: >> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >> Direct replacement does not work. see attachment >> >> More info: >> To reverse engineering saxophones for fdm 3dprinting I use two curve >> approach. >> One curve is path to "extrude" and second is - diameters along this path. >> After bulding tube I place toneholes, posts and etc, defined by length >> from top of tube. >> So I need function to return diameter at given length and angle to rotate >> item I want to place >> I draw curve manually in MOI3D then save as polyline dxf then convert to >> openscad polyline with dxfwread.exe tool. >> I almost solved all the above, but have a feel that there is more elegant >> solution. >> >> Equal spacing along the curve is overkill on straight segments. BSpline >> examples in this maillist seems to be useful but I didnot realize how to >> implement. >> I still didnot understand why length of the resulting tube depends from >> quantization number and how to avoid its changing. >> >> >> >> >> >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >> >> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >> avm4@cornell.edu> wrote: >> >> >> I believe that path_pos_from_start was eliminated because it was >> redundant with path_cut. Can path_cut do what you need? >> >> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >> discuss@lists.openscad.org> wrote: >> >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin <yur_vol@yahoo.com> >> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >> Cc: >> Bcc: >> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >> I use this function in BOLS2 from 2020 for finding point to place an >> item on curved tube. >> It is absent in newer BOLS2. >> What I need to use insteed ? >> >> SY, Yuri >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >> Bcc: >> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >> Bcc: >> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >> Bcc: >> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> >> ---------- Forwarded message ---------- >> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> >> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >> Bcc: >> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >
SP
Sanjeev Prabhakar
Thu, Oct 13, 2022 1:22 AM

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu wrote:

So actually when I said n+1 it should have been n-1.  When I wrote the
replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1] );
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],    diam[1]);
hull(){
path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at i*bl/n
whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).  That
means that you will omit the last sample.  It seems odd, but I was just
duplicating the functionality of your code.  As I have said, there are many
things that look strange, but only you can say if they are in fact wrong.
It does seem like in most places, the incorrect looking code only makes a
small difference in the outcome, like things shift around by less than 1
unit.

If you want to duplicate the current functionality I still think path_cut
is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend on the
obsolete function.  Also attached is a version that uses sweep() the way I
would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu wrote:

I have run your code and I have read it through, and as I have said many
times it appears WRONG.  Whether I am right about that depends on the exact
meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item is
placed at length L from the end of your model?  Or is the intent that the
item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org

Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org

Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors compiling
is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200 code.
There is a list of points in 2d described as "diameter".  It appears that
maybe the second value is the position and the first value the diameter at
that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of cylinders.  I
would do this with sweep.  I would use path_sweep with the transforms=true
option to get a list of transform matrices.  I would apply the scales to
those and then invoke sweep().

For putting objects on the surface you should be able to do it with just
a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org

Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two curve
approach.
One curve is path to "extrude" and second is - diameters along this path.
After bulding tube I place toneholes, posts and etc, defined by length
from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then convert to
openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments. BSpline
examples in this maillist seems to be useful but I didnot realize how to
implement.
I still didnot understand why length of the resulting tube depends from
quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place an
item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org

Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org

Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org

Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I really find this as an interesting application. There should be some generic solution to such modeling applications. [image: Screenshot 2022-10-13 at 6.48.54 AM.png] On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> wrote: > So actually when I said n+1 it should have been n-1. When I wrote the > replacement code I followed your code. In your code you have this loop: > > for (i=[1:1:n-1]){ > diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); > diam = path_pos_from_start(pb,i*bl/n,closed=false); > bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] ); > bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], diam[1]); > hull(){ > path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) > rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); > path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) > rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); > } > } > > The max value of i is n-1. When you calculate diam you do it at i*bl/n > whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). That > means that you will omit the last sample. It seems odd, but I was just > duplicating the functionality of your code. As I have said, there are many > things that look strange, but only you can say if they are in fact wrong. > It does seem like in most places, the incorrect looking code only makes a > small difference in the outcome, like things shift around by less than 1 > unit. > > If you want to duplicate the current functionality I still think path_cut > is the best way to do it: > > module place_item_on_skin(l,angle){ > pathlist = path_cut(pb,l,closed=false); > pt = last(pathlist[0]); > echo(equal=pt[1],pl-l); > color("lightblue") path_spread(p, 1,1,pt[1]) > rotate([90,0,0])translate([0,0,pt[0]/2])children(0); > } > > Attached is a modified version of neck1200.scad that doesn't depend on the > obsolete function. Also attached is a version that uses sweep() the way I > would have coded this model. > > > On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> wrote: > >> I have run your code and I have read it through, and as I have said many >> times it appears WRONG. Whether I am right about that depends on the exact >> meaning of pb. >> >> p = [[0,0],[1,5],[2,100]]; >> echo(path_pos_from_start(p,path_length(p)/2)); >> echo(lookup(1,p)); >> >> The output is >> >> ECHO: [1, 0.473165] >> ECHO: 5 >> >> So please tell me the intention. What do the entries in pb mean >> exactly? I think the reason you don't end where you expect is probably >> that you divided by n instead of n+1 in the loop. >> >> When you use the command place_item(L) is the intention that the item is >> placed at length L from the end of your model? Or is the intent that the >> item is placed somewhere else, approximately L but not exactly L? Your >> existing code does the second thing, not the first one. >> >> >> >> >> >> >> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org >>> > >>> Cc: >>> Bcc: >>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>> I tried your idea but don't get 0.47. It still seems linear >>> interpolatetion here. >>> Please run my code with old paths.scad I attached. It's working code. >>> >>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian Mariano >>> <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>> >>> >>> *When you invoke path_pos_from_start() on the pb variable you are >>> treating pb as a curve in 2d. But from reading your code, it appears that >>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>> as a function of path length along the curve defined by p. I am somewhat >>> guessing here based on the code, but if that is true, then treating it like >>> a curve in 2D will give incorrect results. If we have a simple example:* >>> >>> >>> *p=* >>> *[[0,0],* >>> * [1,5],* >>> * [2,100]]* >>> >>> *where the first entry gives position and the second entry gives >>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>> if you use the method implemented in the neck1000 code which is based on >>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>> of 0.47 instead of 5. You can't assume that the functions will magically >>> produce the right answer even if you ask them to do the wrong thing!* >>> >>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>> path_cut) do is not the same as interpolating a lookup table. A correct >>> way to get that value would be lookup(1,p); I think you can replace every >>> call of path_pos_from_start with lookup and then you won't need the old >>> function. * >>> >>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org >>> > >>> Cc: >>> Bcc: >>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>> As I understand interpolation is done automatically inside the BOLS2 >>> functions. Dont know what exactly method is implemented. >>> You set number of equally spaced interpolation points only for >>> generating tube. It does not depend from how input path set. >>> So you can find a point at given length. >>> For tangent/normal rotating items I set rotate_children=true >>> >>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < >>> avm4@cornell.edu> wrote: >>> >>> >>> I examined neck1200.scad. The problem reported about errors compiling >>> is fixed by removing the "use" statements. >>> >>> However, I'm a little confused about the intent of the neck1200 code. >>> There is a list of points in 2d described as "diameter". It appears that >>> maybe the second value is the position and the first value the diameter at >>> that position. This point list is then operated on using >>> path_pos_from_start. But that doesn't make sense, because the data is not >>> actually a path in 2d. You should be interpolating just on the second >>> coordinate to find position. I would probably do this with lookup()----but >>> the coordinates would need to be swapped first. >>> >>> The code for creating the actual shape is a chain hull of cylinders. I >>> would do this with sweep. I would use path_sweep with the transforms=true >>> option to get a list of transform matrices. I would apply the scales to >>> those and then invoke sweep(). >>> >>> For putting objects on the surface you should be able to do it with just >>> a call to path_spread(), I think. Note that path_cut is not a drop in >>> replacement for path_pos_from_start(). The old function returned an index >>> into the path plus a fraction along the next path segment. The new >>> function takes a list of cut points and returns all the paths cut at those >>> points, so you can then extract the ends that you need directly. >>> >>> Docs for path_cut: >>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>> >>> If you just want the code to work, here's the old function: >>> >>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>> let (lp = len(path)) >>> _i >= lp - (closed?0:1)? undef : >>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>> _d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) : >>> [_i, (length-_d)/l]; >>> >>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org >>> > >>> Cc: >>> Bcc: >>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>> Direct replacement does not work. see attachment >>> >>> More info: >>> To reverse engineering saxophones for fdm 3dprinting I use two curve >>> approach. >>> One curve is path to "extrude" and second is - diameters along this path. >>> After bulding tube I place toneholes, posts and etc, defined by length >>> from top of tube. >>> So I need function to return diameter at given length and angle to >>> rotate item I want to place >>> I draw curve manually in MOI3D then save as polyline dxf then convert to >>> openscad polyline with dxfwread.exe tool. >>> I almost solved all the above, but have a feel that there is more >>> elegant solution. >>> >>> Equal spacing along the curve is overkill on straight segments. BSpline >>> examples in this maillist seems to be useful but I didnot realize how to >>> implement. >>> I still didnot understand why length of the resulting tube depends from >>> quantization number and how to avoid its changing. >>> >>> >>> >>> >>> >>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>> >>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>> avm4@cornell.edu> wrote: >>> >>> >>> I believe that path_pos_from_start was eliminated because it was >>> redundant with path_cut. Can path_cut do what you need? >>> >>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>> Cc: >>> Bcc: >>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>> I use this function in BOLS2 from 2020 for finding point to place an >>> item on curved tube. >>> It is absent in newer BOLS2. >>> What I need to use insteed ? >>> >>> SY, Yuri >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>> Bcc: >>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org >>> > >>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>> Bcc: >>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org >>> > >>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>> Bcc: >>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>> To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org >>> > >>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>> Bcc: >>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Thu, Oct 13, 2022 1:28 AM

missed to attach the code.
I will give it a try this weekend (to make a generic function)

On Thu, 13 Oct 2022 at 06:52, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu wrote:

So actually when I said n+1 it should have been n-1.  When I wrote the
replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1] );
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],    diam[1]);

 hull(){
     path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)

rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at i*bl/n
whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).  That
means that you will omit the last sample.  It seems odd, but I was just
duplicating the functionality of your code.  As I have said, there are many
things that look strange, but only you can say if they are in fact wrong.
It does seem like in most places, the incorrect looking code only makes a
small difference in the outcome, like things shift around by less than 1
unit.

If you want to duplicate the current functionality I still think path_cut
is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend on
the obsolete function.  Also attached is a version that uses sweep() the
way I would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu wrote:

I have run your code and I have read it through, and as I have said many
times it appears WRONG.  Whether I am right about that depends on the exact
meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item is
placed at length L from the end of your model?  Or is the intent that the
item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors compiling
is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200 code.
There is a list of points in 2d described as "diameter".  It appears that
maybe the second value is the position and the first value the diameter at
that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of cylinders.  I
would do this with sweep.  I would use path_sweep with the transforms=true
option to get a list of transform matrices.  I would apply the scales to
those and then invoke sweep().

For putting objects on the surface you should be able to do it with
just a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two curve
approach.
One curve is path to "extrude" and second is - diameters along this
path.
After bulding tube I place toneholes, posts and etc, defined by length
from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then convert
to openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments. BSpline
examples in this maillist seems to be useful but I didnot realize how to
implement.
I still didnot understand why length of the resulting tube depends from
quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place an
item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

missed to attach the code. I will give it a try this weekend (to make a generic function) On Thu, 13 Oct 2022 at 06:52, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > I really find this as an interesting application. > There should be some generic solution to such modeling applications. > [image: Screenshot 2022-10-13 at 6.48.54 AM.png] > > On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> wrote: > >> So actually when I said n+1 it should have been n-1. When I wrote the >> replacement code I followed your code. In your code you have this loop: >> >> for (i=[1:1:n-1]){ >> diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); >> diam = path_pos_from_start(pb,i*bl/n,closed=false); >> bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] ); >> bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], diam[1]); >> >> hull(){ >> path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) >> rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); >> path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) >> rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); >> } >> } >> >> The max value of i is n-1. When you calculate diam you do it at i*bl/n >> whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). That >> means that you will omit the last sample. It seems odd, but I was just >> duplicating the functionality of your code. As I have said, there are many >> things that look strange, but only you can say if they are in fact wrong. >> It does seem like in most places, the incorrect looking code only makes a >> small difference in the outcome, like things shift around by less than 1 >> unit. >> >> If you want to duplicate the current functionality I still think path_cut >> is the best way to do it: >> >> module place_item_on_skin(l,angle){ >> pathlist = path_cut(pb,l,closed=false); >> pt = last(pathlist[0]); >> echo(equal=pt[1],pl-l); >> color("lightblue") path_spread(p, 1,1,pt[1]) >> rotate([90,0,0])translate([0,0,pt[0]/2])children(0); >> } >> >> Attached is a modified version of neck1200.scad that doesn't depend on >> the obsolete function. Also attached is a version that uses sweep() the >> way I would have coded this model. >> >> >> On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> wrote: >> >>> I have run your code and I have read it through, and as I have said many >>> times it appears WRONG. Whether I am right about that depends on the exact >>> meaning of pb. >>> >>> p = [[0,0],[1,5],[2,100]]; >>> echo(path_pos_from_start(p,path_length(p)/2)); >>> echo(lookup(1,p)); >>> >>> The output is >>> >>> ECHO: [1, 0.473165] >>> ECHO: 5 >>> >>> So please tell me the intention. What do the entries in pb mean >>> exactly? I think the reason you don't end where you expect is probably >>> that you divided by n instead of n+1 in the loop. >>> >>> When you use the command place_item(L) is the intention that the item is >>> placed at length L from the end of your model? Or is the intent that the >>> item is placed somewhere else, approximately L but not exactly L? Your >>> existing code does the second thing, not the first one. >>> >>> >>> >>> >>> >>> >>> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> I tried your idea but don't get 0.47. It still seems linear >>>> interpolatetion here. >>>> Please run my code with old paths.scad I attached. It's working code. >>>> >>>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian Mariano >>>> <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>>> >>>> >>>> *When you invoke path_pos_from_start() on the pb variable you are >>>> treating pb as a curve in 2d. But from reading your code, it appears that >>>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>>> as a function of path length along the curve defined by p. I am somewhat >>>> guessing here based on the code, but if that is true, then treating it like >>>> a curve in 2D will give incorrect results. If we have a simple example:* >>>> >>>> >>>> *p=* >>>> *[[0,0],* >>>> * [1,5],* >>>> * [2,100]]* >>>> >>>> *where the first entry gives position and the second entry gives >>>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>>> if you use the method implemented in the neck1000 code which is based on >>>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>>> of 0.47 instead of 5. You can't assume that the functions will magically >>>> produce the right answer even if you ask them to do the wrong thing!* >>>> >>>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>>> path_cut) do is not the same as interpolating a lookup table. A correct >>>> way to get that value would be lookup(1,p); I think you can replace every >>>> call of path_pos_from_start with lookup and then you won't need the old >>>> function. * >>>> >>>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> As I understand interpolation is done automatically inside the BOLS2 >>>> functions. Dont know what exactly method is implemented. >>>> You set number of equally spaced interpolation points only for >>>> generating tube. It does not depend from how input path set. >>>> So you can find a point at given length. >>>> For tangent/normal rotating items I set rotate_children=true >>>> >>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < >>>> avm4@cornell.edu> wrote: >>>> >>>> >>>> I examined neck1200.scad. The problem reported about errors compiling >>>> is fixed by removing the "use" statements. >>>> >>>> However, I'm a little confused about the intent of the neck1200 code. >>>> There is a list of points in 2d described as "diameter". It appears that >>>> maybe the second value is the position and the first value the diameter at >>>> that position. This point list is then operated on using >>>> path_pos_from_start. But that doesn't make sense, because the data is not >>>> actually a path in 2d. You should be interpolating just on the second >>>> coordinate to find position. I would probably do this with lookup()----but >>>> the coordinates would need to be swapped first. >>>> >>>> The code for creating the actual shape is a chain hull of cylinders. I >>>> would do this with sweep. I would use path_sweep with the transforms=true >>>> option to get a list of transform matrices. I would apply the scales to >>>> those and then invoke sweep(). >>>> >>>> For putting objects on the surface you should be able to do it with >>>> just a call to path_spread(), I think. Note that path_cut is not a drop in >>>> replacement for path_pos_from_start(). The old function returned an index >>>> into the path plus a fraction along the next path segment. The new >>>> function takes a list of cut points and returns all the paths cut at those >>>> points, so you can then extract the ends that you need directly. >>>> >>>> Docs for path_cut: >>>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>>> >>>> If you just want the code to work, here's the old function: >>>> >>>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>>> let (lp = len(path)) >>>> _i >= lp - (closed?0:1)? undef : >>>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>>> _d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) : >>>> [_i, (length-_d)/l]; >>>> >>>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> Direct replacement does not work. see attachment >>>> >>>> More info: >>>> To reverse engineering saxophones for fdm 3dprinting I use two curve >>>> approach. >>>> One curve is path to "extrude" and second is - diameters along this >>>> path. >>>> After bulding tube I place toneholes, posts and etc, defined by length >>>> from top of tube. >>>> So I need function to return diameter at given length and angle to >>>> rotate item I want to place >>>> I draw curve manually in MOI3D then save as polyline dxf then convert >>>> to openscad polyline with dxfwread.exe tool. >>>> I almost solved all the above, but have a feel that there is more >>>> elegant solution. >>>> >>>> Equal spacing along the curve is overkill on straight segments. BSpline >>>> examples in this maillist seems to be useful but I didnot realize how to >>>> implement. >>>> I still didnot understand why length of the resulting tube depends from >>>> quantization number and how to avoid its changing. >>>> >>>> >>>> >>>> >>>> >>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> >>>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>>> avm4@cornell.edu> wrote: >>>> >>>> >>>> I believe that path_pos_from_start was eliminated because it was >>>> redundant with path_cut. Can path_cut do what you need? >>>> >>>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>> I use this function in BOLS2 from 2020 for finding point to place an >>>> item on curved tube. >>>> It is absent in newer BOLS2. >>>> What I need to use insteed ? >>>> >>>> SY, Yuri >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >
AM
Adrian Mariano
Thu, Oct 13, 2022 1:59 AM

What exactly are you envisioning?  In BOSL2 I have sweep() which is
extremely general and can do this, though because of generality, it is also
more difficult to use.  I was pondering if I should add scaling to the
regular path_sweep() module.  I think this would be an easy addition.

On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu wrote:

So actually when I said n+1 it should have been n-1.  When I wrote the
replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1] );
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],    diam[1]);

 hull(){
     path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)

rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at i*bl/n
whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).  That
means that you will omit the last sample.  It seems odd, but I was just
duplicating the functionality of your code.  As I have said, there are many
things that look strange, but only you can say if they are in fact wrong.
It does seem like in most places, the incorrect looking code only makes a
small difference in the outcome, like things shift around by less than 1
unit.

If you want to duplicate the current functionality I still think path_cut
is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend on
the obsolete function.  Also attached is a version that uses sweep() the
way I would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu wrote:

I have run your code and I have read it through, and as I have said many
times it appears WRONG.  Whether I am right about that depends on the exact
meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item is
placed at length L from the end of your model?  Or is the intent that the
item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors compiling
is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200 code.
There is a list of points in 2d described as "diameter".  It appears that
maybe the second value is the position and the first value the diameter at
that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of cylinders.  I
would do this with sweep.  I would use path_sweep with the transforms=true
option to get a list of transform matrices.  I would apply the scales to
those and then invoke sweep().

For putting objects on the surface you should be able to do it with
just a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two curve
approach.
One curve is path to "extrude" and second is - diameters along this
path.
After bulding tube I place toneholes, posts and etc, defined by length
from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then convert
to openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments. BSpline
examples in this maillist seems to be useful but I didnot realize how to
implement.
I still didnot understand why length of the resulting tube depends from
quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place an
item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

What exactly are you envisioning? In BOSL2 I have sweep() which is extremely general and can do this, though because of generality, it is also more difficult to use. I was pondering if I should add scaling to the regular path_sweep() module. I think this would be an easy addition. On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > I really find this as an interesting application. > There should be some generic solution to such modeling applications. > [image: Screenshot 2022-10-13 at 6.48.54 AM.png] > > On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> wrote: > >> So actually when I said n+1 it should have been n-1. When I wrote the >> replacement code I followed your code. In your code you have this loop: >> >> for (i=[1:1:n-1]){ >> diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); >> diam = path_pos_from_start(pb,i*bl/n,closed=false); >> bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] ); >> bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], diam[1]); >> >> hull(){ >> path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) >> rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); >> path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) >> rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); >> } >> } >> >> The max value of i is n-1. When you calculate diam you do it at i*bl/n >> whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). That >> means that you will omit the last sample. It seems odd, but I was just >> duplicating the functionality of your code. As I have said, there are many >> things that look strange, but only you can say if they are in fact wrong. >> It does seem like in most places, the incorrect looking code only makes a >> small difference in the outcome, like things shift around by less than 1 >> unit. >> >> If you want to duplicate the current functionality I still think path_cut >> is the best way to do it: >> >> module place_item_on_skin(l,angle){ >> pathlist = path_cut(pb,l,closed=false); >> pt = last(pathlist[0]); >> echo(equal=pt[1],pl-l); >> color("lightblue") path_spread(p, 1,1,pt[1]) >> rotate([90,0,0])translate([0,0,pt[0]/2])children(0); >> } >> >> Attached is a modified version of neck1200.scad that doesn't depend on >> the obsolete function. Also attached is a version that uses sweep() the >> way I would have coded this model. >> >> >> On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> wrote: >> >>> I have run your code and I have read it through, and as I have said many >>> times it appears WRONG. Whether I am right about that depends on the exact >>> meaning of pb. >>> >>> p = [[0,0],[1,5],[2,100]]; >>> echo(path_pos_from_start(p,path_length(p)/2)); >>> echo(lookup(1,p)); >>> >>> The output is >>> >>> ECHO: [1, 0.473165] >>> ECHO: 5 >>> >>> So please tell me the intention. What do the entries in pb mean >>> exactly? I think the reason you don't end where you expect is probably >>> that you divided by n instead of n+1 in the loop. >>> >>> When you use the command place_item(L) is the intention that the item is >>> placed at length L from the end of your model? Or is the intent that the >>> item is placed somewhere else, approximately L but not exactly L? Your >>> existing code does the second thing, not the first one. >>> >>> >>> >>> >>> >>> >>> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> I tried your idea but don't get 0.47. It still seems linear >>>> interpolatetion here. >>>> Please run my code with old paths.scad I attached. It's working code. >>>> >>>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian Mariano >>>> <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>>> >>>> >>>> *When you invoke path_pos_from_start() on the pb variable you are >>>> treating pb as a curve in 2d. But from reading your code, it appears that >>>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>>> as a function of path length along the curve defined by p. I am somewhat >>>> guessing here based on the code, but if that is true, then treating it like >>>> a curve in 2D will give incorrect results. If we have a simple example:* >>>> >>>> >>>> *p=* >>>> *[[0,0],* >>>> * [1,5],* >>>> * [2,100]]* >>>> >>>> *where the first entry gives position and the second entry gives >>>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>>> if you use the method implemented in the neck1000 code which is based on >>>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>>> of 0.47 instead of 5. You can't assume that the functions will magically >>>> produce the right answer even if you ask them to do the wrong thing!* >>>> >>>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>>> path_cut) do is not the same as interpolating a lookup table. A correct >>>> way to get that value would be lookup(1,p); I think you can replace every >>>> call of path_pos_from_start with lookup and then you won't need the old >>>> function. * >>>> >>>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> As I understand interpolation is done automatically inside the BOLS2 >>>> functions. Dont know what exactly method is implemented. >>>> You set number of equally spaced interpolation points only for >>>> generating tube. It does not depend from how input path set. >>>> So you can find a point at given length. >>>> For tangent/normal rotating items I set rotate_children=true >>>> >>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < >>>> avm4@cornell.edu> wrote: >>>> >>>> >>>> I examined neck1200.scad. The problem reported about errors compiling >>>> is fixed by removing the "use" statements. >>>> >>>> However, I'm a little confused about the intent of the neck1200 code. >>>> There is a list of points in 2d described as "diameter". It appears that >>>> maybe the second value is the position and the first value the diameter at >>>> that position. This point list is then operated on using >>>> path_pos_from_start. But that doesn't make sense, because the data is not >>>> actually a path in 2d. You should be interpolating just on the second >>>> coordinate to find position. I would probably do this with lookup()----but >>>> the coordinates would need to be swapped first. >>>> >>>> The code for creating the actual shape is a chain hull of cylinders. I >>>> would do this with sweep. I would use path_sweep with the transforms=true >>>> option to get a list of transform matrices. I would apply the scales to >>>> those and then invoke sweep(). >>>> >>>> For putting objects on the surface you should be able to do it with >>>> just a call to path_spread(), I think. Note that path_cut is not a drop in >>>> replacement for path_pos_from_start(). The old function returned an index >>>> into the path plus a fraction along the next path segment. The new >>>> function takes a list of cut points and returns all the paths cut at those >>>> points, so you can then extract the ends that you need directly. >>>> >>>> Docs for path_cut: >>>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>>> >>>> If you just want the code to work, here's the old function: >>>> >>>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>>> let (lp = len(path)) >>>> _i >= lp - (closed?0:1)? undef : >>>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>>> _d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) : >>>> [_i, (length-_d)/l]; >>>> >>>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> Direct replacement does not work. see attachment >>>> >>>> More info: >>>> To reverse engineering saxophones for fdm 3dprinting I use two curve >>>> approach. >>>> One curve is path to "extrude" and second is - diameters along this >>>> path. >>>> After bulding tube I place toneholes, posts and etc, defined by length >>>> from top of tube. >>>> So I need function to return diameter at given length and angle to >>>> rotate item I want to place >>>> I draw curve manually in MOI3D then save as polyline dxf then convert >>>> to openscad polyline with dxfwread.exe tool. >>>> I almost solved all the above, but have a feel that there is more >>>> elegant solution. >>>> >>>> Equal spacing along the curve is overkill on straight segments. BSpline >>>> examples in this maillist seems to be useful but I didnot realize how to >>>> implement. >>>> I still didnot understand why length of the resulting tube depends from >>>> quantization number and how to avoid its changing. >>>> >>>> >>>> >>>> >>>> >>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> >>>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>>> avm4@cornell.edu> wrote: >>>> >>>> >>>> I believe that path_pos_from_start was eliminated because it was >>>> redundant with path_cut. Can path_cut do what you need? >>>> >>>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> Cc: >>>> Bcc: >>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>> I use this function in BOLS2 from 2020 for finding point to place an >>>> item on curved tube. >>>> It is absent in newer BOLS2. >>>> What I need to use insteed ? >>>> >>>> SY, Yuri >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>> To: OpenSCAD general discussion Mailing-list < >>>> discuss@lists.openscad.org> >>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>> Bcc: >>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Thu, Oct 13, 2022 2:15 AM

The application should have capability to

  1. Place different sections (not necessarily circular, it can be a
    combination) at defined location in a path
  2. smoother transition of sections with no sharp corners
    3.Path can be in different planes
  3. Maybe input 5 sections and 5 index locations in a path (max)
    5.Simple for enduser

On Thu, 13 Oct 2022, 07:30 Adrian Mariano, avm4@cornell.edu wrote:

What exactly are you envisioning?  In BOSL2 I have sweep() which is
extremely general and can do this, though because of generality, it is also
more difficult to use.  I was pondering if I should add scaling to the
regular path_sweep() module.  I think this would be an easy addition.

On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu wrote:

So actually when I said n+1 it should have been n-1.  When I wrote the
replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1] );
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],
diam[1]);
hull(){
path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at i*bl/n
whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).  That
means that you will omit the last sample.  It seems odd, but I was just
duplicating the functionality of your code.  As I have said, there are many
things that look strange, but only you can say if they are in fact wrong.
It does seem like in most places, the incorrect looking code only makes a
small difference in the outcome, like things shift around by less than 1
unit.

If you want to duplicate the current functionality I still think
path_cut is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend on
the obsolete function.  Also attached is a version that uses sweep() the
way I would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu wrote:

I have run your code and I have read it through, and as I have said
many times it appears WRONG.  Whether I am right about that depends on the
exact meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item
is placed at length L from the end of your model?  Or is the intent that
the item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors compiling
is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200 code.
There is a list of points in 2d described as "diameter".  It appears that
maybe the second value is the position and the first value the diameter at
that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of cylinders.
I would do this with sweep.  I would use path_sweep with the
transforms=true option to get a list of transform matrices.  I would apply
the scales to those and then invoke sweep().

For putting objects on the surface you should be able to do it with
just a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two curve
approach.
One curve is path to "extrude" and second is - diameters along this
path.
After bulding tube I place toneholes, posts and etc, defined by length
from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then convert
to openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments.
BSpline examples in this maillist seems to be useful but I didnot realize
how to implement.
I still didnot understand why length of the resulting tube depends
from quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place an
item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

The application should have capability to 1. Place different sections (not necessarily circular, it can be a combination) at defined location in a path 2. smoother transition of sections with no sharp corners 3.Path can be in different planes 4. Maybe input 5 sections and 5 index locations in a path (max) 5.Simple for enduser On Thu, 13 Oct 2022, 07:30 Adrian Mariano, <avm4@cornell.edu> wrote: > What exactly are you envisioning? In BOSL2 I have sweep() which is > extremely general and can do this, though because of generality, it is also > more difficult to use. I was pondering if I should add scaling to the > regular path_sweep() module. I think this would be an easy addition. > > On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar < > sprabhakar2006@gmail.com> wrote: > >> I really find this as an interesting application. >> There should be some generic solution to such modeling applications. >> [image: Screenshot 2022-10-13 at 6.48.54 AM.png] >> >> On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> wrote: >> >>> So actually when I said n+1 it should have been n-1. When I wrote the >>> replacement code I followed your code. In your code you have this loop: >>> >>> for (i=[1:1:n-1]){ >>> diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); >>> diam = path_pos_from_start(pb,i*bl/n,closed=false); >>> bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] ); >>> bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], >>> diam[1]); >>> hull(){ >>> path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) >>> rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); >>> path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) >>> rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); >>> } >>> } >>> >>> The max value of i is n-1. When you calculate diam you do it at i*bl/n >>> whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). That >>> means that you will omit the last sample. It seems odd, but I was just >>> duplicating the functionality of your code. As I have said, there are many >>> things that look strange, but only you can say if they are in fact wrong. >>> It does seem like in most places, the incorrect looking code only makes a >>> small difference in the outcome, like things shift around by less than 1 >>> unit. >>> >>> If you want to duplicate the current functionality I still think >>> path_cut is the best way to do it: >>> >>> module place_item_on_skin(l,angle){ >>> pathlist = path_cut(pb,l,closed=false); >>> pt = last(pathlist[0]); >>> echo(equal=pt[1],pl-l); >>> color("lightblue") path_spread(p, 1,1,pt[1]) >>> rotate([90,0,0])translate([0,0,pt[0]/2])children(0); >>> } >>> >>> Attached is a modified version of neck1200.scad that doesn't depend on >>> the obsolete function. Also attached is a version that uses sweep() the >>> way I would have coded this model. >>> >>> >>> On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> wrote: >>> >>>> I have run your code and I have read it through, and as I have said >>>> many times it appears WRONG. Whether I am right about that depends on the >>>> exact meaning of pb. >>>> >>>> p = [[0,0],[1,5],[2,100]]; >>>> echo(path_pos_from_start(p,path_length(p)/2)); >>>> echo(lookup(1,p)); >>>> >>>> The output is >>>> >>>> ECHO: [1, 0.473165] >>>> ECHO: 5 >>>> >>>> So please tell me the intention. What do the entries in pb mean >>>> exactly? I think the reason you don't end where you expect is probably >>>> that you divided by n instead of n+1 in the loop. >>>> >>>> When you use the command place_item(L) is the intention that the item >>>> is placed at length L from the end of your model? Or is the intent that >>>> the item is placed somewhere else, approximately L but not exactly L? Your >>>> existing code does the second thing, not the first one. >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> To: OpenSCAD general discussion Mailing-list < >>>>> discuss@lists.openscad.org> >>>>> Cc: >>>>> Bcc: >>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>> I tried your idea but don't get 0.47. It still seems linear >>>>> interpolatetion here. >>>>> Please run my code with old paths.scad I attached. It's working code. >>>>> >>>>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian Mariano >>>>> <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>>>> >>>>> >>>>> *When you invoke path_pos_from_start() on the pb variable you are >>>>> treating pb as a curve in 2d. But from reading your code, it appears that >>>>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>>>> as a function of path length along the curve defined by p. I am somewhat >>>>> guessing here based on the code, but if that is true, then treating it like >>>>> a curve in 2D will give incorrect results. If we have a simple example:* >>>>> >>>>> >>>>> *p=* >>>>> *[[0,0],* >>>>> * [1,5],* >>>>> * [2,100]]* >>>>> >>>>> *where the first entry gives position and the second entry gives >>>>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>>>> if you use the method implemented in the neck1000 code which is based on >>>>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>>>> of 0.47 instead of 5. You can't assume that the functions will magically >>>>> produce the right answer even if you ask them to do the wrong thing!* >>>>> >>>>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>>>> path_cut) do is not the same as interpolating a lookup table. A correct >>>>> way to get that value would be lookup(1,p); I think you can replace every >>>>> call of path_pos_from_start with lookup and then you won't need the old >>>>> function. * >>>>> >>>>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>>>> discuss@lists.openscad.org> wrote: >>>>> >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> To: OpenSCAD general discussion Mailing-list < >>>>> discuss@lists.openscad.org> >>>>> Cc: >>>>> Bcc: >>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>> As I understand interpolation is done automatically inside the BOLS2 >>>>> functions. Dont know what exactly method is implemented. >>>>> You set number of equally spaced interpolation points only for >>>>> generating tube. It does not depend from how input path set. >>>>> So you can find a point at given length. >>>>> For tangent/normal rotating items I set rotate_children=true >>>>> >>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < >>>>> avm4@cornell.edu> wrote: >>>>> >>>>> >>>>> I examined neck1200.scad. The problem reported about errors compiling >>>>> is fixed by removing the "use" statements. >>>>> >>>>> However, I'm a little confused about the intent of the neck1200 code. >>>>> There is a list of points in 2d described as "diameter". It appears that >>>>> maybe the second value is the position and the first value the diameter at >>>>> that position. This point list is then operated on using >>>>> path_pos_from_start. But that doesn't make sense, because the data is not >>>>> actually a path in 2d. You should be interpolating just on the second >>>>> coordinate to find position. I would probably do this with lookup()----but >>>>> the coordinates would need to be swapped first. >>>>> >>>>> The code for creating the actual shape is a chain hull of cylinders. >>>>> I would do this with sweep. I would use path_sweep with the >>>>> transforms=true option to get a list of transform matrices. I would apply >>>>> the scales to those and then invoke sweep(). >>>>> >>>>> For putting objects on the surface you should be able to do it with >>>>> just a call to path_spread(), I think. Note that path_cut is not a drop in >>>>> replacement for path_pos_from_start(). The old function returned an index >>>>> into the path plus a fraction along the next path segment. The new >>>>> function takes a list of cut points and returns all the paths cut at those >>>>> points, so you can then extract the ends that you need directly. >>>>> >>>>> Docs for path_cut: >>>>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>>>> >>>>> If you just want the code to work, here's the old function: >>>>> >>>>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>>>> let (lp = len(path)) >>>>> _i >= lp - (closed?0:1)? undef : >>>>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>>>> _d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) : >>>>> [_i, (length-_d)/l]; >>>>> >>>>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>>>> discuss@lists.openscad.org> wrote: >>>>> >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> To: OpenSCAD general discussion Mailing-list < >>>>> discuss@lists.openscad.org> >>>>> Cc: >>>>> Bcc: >>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>> Direct replacement does not work. see attachment >>>>> >>>>> More info: >>>>> To reverse engineering saxophones for fdm 3dprinting I use two curve >>>>> approach. >>>>> One curve is path to "extrude" and second is - diameters along this >>>>> path. >>>>> After bulding tube I place toneholes, posts and etc, defined by length >>>>> from top of tube. >>>>> So I need function to return diameter at given length and angle to >>>>> rotate item I want to place >>>>> I draw curve manually in MOI3D then save as polyline dxf then convert >>>>> to openscad polyline with dxfwread.exe tool. >>>>> I almost solved all the above, but have a feel that there is more >>>>> elegant solution. >>>>> >>>>> Equal spacing along the curve is overkill on straight segments. >>>>> BSpline examples in this maillist seems to be useful but I didnot realize >>>>> how to implement. >>>>> I still didnot understand why length of the resulting tube depends >>>>> from quantization number and how to avoid its changing. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>> >>>>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>>>> avm4@cornell.edu> wrote: >>>>> >>>>> >>>>> I believe that path_pos_from_start was eliminated because it was >>>>> redundant with path_cut. Can path_cut do what you need? >>>>> >>>>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>>>> discuss@lists.openscad.org> wrote: >>>>> >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>> Cc: >>>>> Bcc: >>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>> I use this function in BOLS2 from 2020 for finding point to place an >>>>> item on curved tube. >>>>> It is absent in newer BOLS2. >>>>> What I need to use insteed ? >>>>> >>>>> SY, Yuri >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> Bcc: >>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>> To: OpenSCAD general discussion Mailing-list < >>>>> discuss@lists.openscad.org> >>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> Bcc: >>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>> To: OpenSCAD general discussion Mailing-list < >>>>> discuss@lists.openscad.org> >>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> Bcc: >>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>> To: OpenSCAD general discussion Mailing-list < >>>>> discuss@lists.openscad.org> >>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>> Bcc: >>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Thu, Oct 13, 2022 2:36 AM

So you're suggesting the following:  Given a path, a list of N points on
the path, and N sections to be located at those points, create a polyhedron
that passes through the sections in a "smooth" manner.  The skin() module
does this, except it doesn't attempt to satisfy any smoothness
constraints.  From my experience in writing skin() I can say it will be
very hard to be fully general.  You probably want to require that each
section has the same number of points and that point 0 matches to point 0
on each section.  (See the BOSL2 skin documentation for various attempts to
address the cases when these requirements fail.)

To satisfy a smoothness constraint seems challenging.  You can construct a
bezier that passes through all the corresponding points of the sections,
perhaps?  It won't necessarily have anything to do with the path, though,
and could produce asymmetric results for symmetric inputs, I suspect.  That
is, controlling the direction in which it curves to create smoothness might
be difficult.

On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

The application should have capability to

  1. Place different sections (not necessarily circular, it can be a
    combination) at defined location in a path
  2. smoother transition of sections with no sharp corners
    3.Path can be in different planes
  3. Maybe input 5 sections and 5 index locations in a path (max)
    5.Simple for enduser

On Thu, 13 Oct 2022, 07:30 Adrian Mariano, avm4@cornell.edu wrote:

What exactly are you envisioning?  In BOSL2 I have sweep() which is
extremely general and can do this, though because of generality, it is also
more difficult to use.  I was pondering if I should add scaling to the
regular path_sweep() module.  I think this would be an easy addition.

On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu wrote:

So actually when I said n+1 it should have been n-1.  When I wrote the
replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1] );
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],
diam[1]);
hull(){
path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at i*bl/n
whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).  That
means that you will omit the last sample.  It seems odd, but I was just
duplicating the functionality of your code.  As I have said, there are many
things that look strange, but only you can say if they are in fact wrong.
It does seem like in most places, the incorrect looking code only makes a
small difference in the outcome, like things shift around by less than 1
unit.

If you want to duplicate the current functionality I still think
path_cut is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend on
the obsolete function.  Also attached is a version that uses sweep() the
way I would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu
wrote:

I have run your code and I have read it through, and as I have said
many times it appears WRONG.  Whether I am right about that depends on the
exact meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item
is placed at length L from the end of your model?  Or is the intent that
the item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors
compiling is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200
code.  There is a list of points in 2d described as "diameter".  It appears
that maybe the second value is the position and the first value the
diameter at that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of cylinders.
I would do this with sweep.  I would use path_sweep with the
transforms=true option to get a list of transform matrices.  I would apply
the scales to those and then invoke sweep().

For putting objects on the surface you should be able to do it with
just a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1)
:
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two curve
approach.
One curve is path to "extrude" and second is - diameters along this
path.
After bulding tube I place toneholes, posts and etc, defined by
length from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then convert
to openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments.
BSpline examples in this maillist seems to be useful but I didnot realize
how to implement.
I still didnot understand why length of the resulting tube depends
from quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place an
item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

So you're suggesting the following: Given a path, a list of N points on the path, and N sections to be located at those points, create a polyhedron that passes through the sections in a "smooth" manner. The skin() module does this, except it doesn't attempt to satisfy any smoothness constraints. From my experience in writing skin() I can say it will be very hard to be fully general. You probably want to require that each section has the same number of points and that point 0 matches to point 0 on each section. (See the BOSL2 skin documentation for various attempts to address the cases when these requirements fail.) To satisfy a smoothness constraint seems challenging. You can construct a bezier that passes through all the corresponding points of the sections, perhaps? It won't necessarily have anything to do with the path, though, and could produce asymmetric results for symmetric inputs, I suspect. That is, controlling the direction in which it curves to create smoothness might be difficult. On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > The application should have capability to > 1. Place different sections (not necessarily circular, it can be a > combination) at defined location in a path > 2. smoother transition of sections with no sharp corners > 3.Path can be in different planes > 4. Maybe input 5 sections and 5 index locations in a path (max) > 5.Simple for enduser > > > On Thu, 13 Oct 2022, 07:30 Adrian Mariano, <avm4@cornell.edu> wrote: > >> What exactly are you envisioning? In BOSL2 I have sweep() which is >> extremely general and can do this, though because of generality, it is also >> more difficult to use. I was pondering if I should add scaling to the >> regular path_sweep() module. I think this would be an easy addition. >> >> On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar < >> sprabhakar2006@gmail.com> wrote: >> >>> I really find this as an interesting application. >>> There should be some generic solution to such modeling applications. >>> [image: Screenshot 2022-10-13 at 6.48.54 AM.png] >>> >>> On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> wrote: >>> >>>> So actually when I said n+1 it should have been n-1. When I wrote the >>>> replacement code I followed your code. In your code you have this loop: >>>> >>>> for (i=[1:1:n-1]){ >>>> diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); >>>> diam = path_pos_from_start(pb,i*bl/n,closed=false); >>>> bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] ); >>>> bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], >>>> diam[1]); >>>> hull(){ >>>> path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) >>>> rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); >>>> path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) >>>> rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); >>>> } >>>> } >>>> >>>> The max value of i is n-1. When you calculate diam you do it at i*bl/n >>>> whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). That >>>> means that you will omit the last sample. It seems odd, but I was just >>>> duplicating the functionality of your code. As I have said, there are many >>>> things that look strange, but only you can say if they are in fact wrong. >>>> It does seem like in most places, the incorrect looking code only makes a >>>> small difference in the outcome, like things shift around by less than 1 >>>> unit. >>>> >>>> If you want to duplicate the current functionality I still think >>>> path_cut is the best way to do it: >>>> >>>> module place_item_on_skin(l,angle){ >>>> pathlist = path_cut(pb,l,closed=false); >>>> pt = last(pathlist[0]); >>>> echo(equal=pt[1],pl-l); >>>> color("lightblue") path_spread(p, 1,1,pt[1]) >>>> rotate([90,0,0])translate([0,0,pt[0]/2])children(0); >>>> } >>>> >>>> Attached is a modified version of neck1200.scad that doesn't depend on >>>> the obsolete function. Also attached is a version that uses sweep() the >>>> way I would have coded this model. >>>> >>>> >>>> On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> >>>> wrote: >>>> >>>>> I have run your code and I have read it through, and as I have said >>>>> many times it appears WRONG. Whether I am right about that depends on the >>>>> exact meaning of pb. >>>>> >>>>> p = [[0,0],[1,5],[2,100]]; >>>>> echo(path_pos_from_start(p,path_length(p)/2)); >>>>> echo(lookup(1,p)); >>>>> >>>>> The output is >>>>> >>>>> ECHO: [1, 0.473165] >>>>> ECHO: 5 >>>>> >>>>> So please tell me the intention. What do the entries in pb mean >>>>> exactly? I think the reason you don't end where you expect is probably >>>>> that you divided by n instead of n+1 in the loop. >>>>> >>>>> When you use the command place_item(L) is the intention that the item >>>>> is placed at length L from the end of your model? Or is the intent that >>>>> the item is placed somewhere else, approximately L but not exactly L? Your >>>>> existing code does the second thing, not the first one. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >>>>> discuss@lists.openscad.org> wrote: >>>>> >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>> discuss@lists.openscad.org> >>>>>> Cc: >>>>>> Bcc: >>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>> I tried your idea but don't get 0.47. It still seems linear >>>>>> interpolatetion here. >>>>>> Please run my code with old paths.scad I attached. It's working code. >>>>>> >>>>>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian Mariano >>>>>> <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>>>>> >>>>>> >>>>>> *When you invoke path_pos_from_start() on the pb variable you are >>>>>> treating pb as a curve in 2d. But from reading your code, it appears that >>>>>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>>>>> as a function of path length along the curve defined by p. I am somewhat >>>>>> guessing here based on the code, but if that is true, then treating it like >>>>>> a curve in 2D will give incorrect results. If we have a simple example:* >>>>>> >>>>>> >>>>>> *p=* >>>>>> *[[0,0],* >>>>>> * [1,5],* >>>>>> * [2,100]]* >>>>>> >>>>>> *where the first entry gives position and the second entry gives >>>>>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>>>>> if you use the method implemented in the neck1000 code which is based on >>>>>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>>>>> of 0.47 instead of 5. You can't assume that the functions will magically >>>>>> produce the right answer even if you ask them to do the wrong thing!* >>>>>> >>>>>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>>>>> path_cut) do is not the same as interpolating a lookup table. A correct >>>>>> way to get that value would be lookup(1,p); I think you can replace every >>>>>> call of path_pos_from_start with lookup and then you won't need the old >>>>>> function. * >>>>>> >>>>>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>>>>> discuss@lists.openscad.org> wrote: >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>> discuss@lists.openscad.org> >>>>>> Cc: >>>>>> Bcc: >>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>> As I understand interpolation is done automatically inside the BOLS2 >>>>>> functions. Dont know what exactly method is implemented. >>>>>> You set number of equally spaced interpolation points only for >>>>>> generating tube. It does not depend from how input path set. >>>>>> So you can find a point at given length. >>>>>> For tangent/normal rotating items I set rotate_children=true >>>>>> >>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < >>>>>> avm4@cornell.edu> wrote: >>>>>> >>>>>> >>>>>> I examined neck1200.scad. The problem reported about errors >>>>>> compiling is fixed by removing the "use" statements. >>>>>> >>>>>> However, I'm a little confused about the intent of the neck1200 >>>>>> code. There is a list of points in 2d described as "diameter". It appears >>>>>> that maybe the second value is the position and the first value the >>>>>> diameter at that position. This point list is then operated on using >>>>>> path_pos_from_start. But that doesn't make sense, because the data is not >>>>>> actually a path in 2d. You should be interpolating just on the second >>>>>> coordinate to find position. I would probably do this with lookup()----but >>>>>> the coordinates would need to be swapped first. >>>>>> >>>>>> The code for creating the actual shape is a chain hull of cylinders. >>>>>> I would do this with sweep. I would use path_sweep with the >>>>>> transforms=true option to get a list of transform matrices. I would apply >>>>>> the scales to those and then invoke sweep(). >>>>>> >>>>>> For putting objects on the surface you should be able to do it with >>>>>> just a call to path_spread(), I think. Note that path_cut is not a drop in >>>>>> replacement for path_pos_from_start(). The old function returned an index >>>>>> into the path plus a fraction along the next path segment. The new >>>>>> function takes a list of cut points and returns all the paths cut at those >>>>>> points, so you can then extract the ends that you need directly. >>>>>> >>>>>> Docs for path_cut: >>>>>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>>>>> >>>>>> If you just want the code to work, here's the old function: >>>>>> >>>>>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>>>>> let (lp = len(path)) >>>>>> _i >= lp - (closed?0:1)? undef : >>>>>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>>>>> _d+l <= length? path_pos_from_start(path,length,closed,_d+l,_i+1) >>>>>> : >>>>>> [_i, (length-_d)/l]; >>>>>> >>>>>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>>>>> discuss@lists.openscad.org> wrote: >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>> discuss@lists.openscad.org> >>>>>> Cc: >>>>>> Bcc: >>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>> Direct replacement does not work. see attachment >>>>>> >>>>>> More info: >>>>>> To reverse engineering saxophones for fdm 3dprinting I use two curve >>>>>> approach. >>>>>> One curve is path to "extrude" and second is - diameters along this >>>>>> path. >>>>>> After bulding tube I place toneholes, posts and etc, defined by >>>>>> length from top of tube. >>>>>> So I need function to return diameter at given length and angle to >>>>>> rotate item I want to place >>>>>> I draw curve manually in MOI3D then save as polyline dxf then convert >>>>>> to openscad polyline with dxfwread.exe tool. >>>>>> I almost solved all the above, but have a feel that there is more >>>>>> elegant solution. >>>>>> >>>>>> Equal spacing along the curve is overkill on straight segments. >>>>>> BSpline examples in this maillist seems to be useful but I didnot realize >>>>>> how to implement. >>>>>> I still didnot understand why length of the resulting tube depends >>>>>> from quantization number and how to avoid its changing. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>> >>>>>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>>>>> avm4@cornell.edu> wrote: >>>>>> >>>>>> >>>>>> I believe that path_pos_from_start was eliminated because it was >>>>>> redundant with path_cut. Can path_cut do what you need? >>>>>> >>>>>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>>>>> discuss@lists.openscad.org> wrote: >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>> Cc: >>>>>> Bcc: >>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>> I use this function in BOLS2 from 2020 for finding point to place an >>>>>> item on curved tube. >>>>>> It is absent in newer BOLS2. >>>>>> What I need to use insteed ? >>>>>> >>>>>> SY, Yuri >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> Bcc: >>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>> discuss@lists.openscad.org> >>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> Bcc: >>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>> discuss@lists.openscad.org> >>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> Bcc: >>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>>> >>>>>> >>>>>> ---------- Forwarded message ---------- >>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>> discuss@lists.openscad.org> >>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>> Bcc: >>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Thu, Oct 13, 2022 2:48 AM

I need to read the sweep and skin functions you mentioned.
What I want is

  • may be 5 different sections
  • path has only 5 points
  • radius at each point in the path
  • smoother transition from 1 section to another

Function should develop a polyhedron

On Thu, 13 Oct, 2022, 8:07 am Adrian Mariano, avm4@cornell.edu wrote:

So you're suggesting the following:  Given a path, a list of N points on
the path, and N sections to be located at those points, create a polyhedron
that passes through the sections in a "smooth" manner.  The skin() module
does this, except it doesn't attempt to satisfy any smoothness
constraints.  From my experience in writing skin() I can say it will be
very hard to be fully general.  You probably want to require that each
section has the same number of points and that point 0 matches to point 0
on each section.  (See the BOSL2 skin documentation for various attempts to
address the cases when these requirements fail.)

To satisfy a smoothness constraint seems challenging.  You can construct a
bezier that passes through all the corresponding points of the sections,
perhaps?  It won't necessarily have anything to do with the path, though,
and could produce asymmetric results for symmetric inputs, I suspect.  That
is, controlling the direction in which it curves to create smoothness might
be difficult.

On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

The application should have capability to

  1. Place different sections (not necessarily circular, it can be a
    combination) at defined location in a path
  2. smoother transition of sections with no sharp corners
    3.Path can be in different planes
  3. Maybe input 5 sections and 5 index locations in a path (max)
    5.Simple for enduser

On Thu, 13 Oct 2022, 07:30 Adrian Mariano, avm4@cornell.edu wrote:

What exactly are you envisioning?  In BOSL2 I have sweep() which is
extremely general and can do this, though because of generality, it is also
more difficult to use.  I was pondering if I should add scaling to the
regular path_sweep() module.  I think this would be an easy addition.

On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu wrote:

So actually when I said n+1 it should have been n-1.  When I wrote the
replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1]
);
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],
diam[1]);
hull(){
path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at
i*bl/n whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).
That means that you will omit the last sample.  It seems odd, but I was
just duplicating the functionality of your code.  As I have said, there are
many things that look strange, but only you can say if they are in fact
wrong.  It does seem like in most places, the incorrect looking code only
makes a small difference in the outcome, like things shift around by less
than 1 unit.

If you want to duplicate the current functionality I still think
path_cut is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend on
the obsolete function.  Also attached is a version that uses sweep() the
way I would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu
wrote:

I have run your code and I have read it through, and as I have said
many times it appears WRONG.  Whether I am right about that depends on the
exact meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the item
is placed at length L from the end of your model?  Or is the intent that
the item is placed somewhere else, approximately L but not exactly L?  Your
existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the BOLS2
functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I examined neck1200.scad.  The problem reported about errors
compiling is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200
code.  There is a list of points in 2d described as "diameter".  It appears
that maybe the second value is the position and the first value the
diameter at that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of
cylinders.  I would do this with sweep.  I would use path_sweep with the
transforms=true option to get a list of transform matrices.  I would apply
the scales to those and then invoke sweep().

For putting objects on the surface you should be able to do it with
just a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length?
path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two
curve approach.
One curve is path to "extrude" and second is - diameters along this
path.
After bulding tube I place toneholes, posts and etc, defined by
length from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then
convert to openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments.
BSpline examples in this maillist seems to be useful but I didnot realize
how to implement.
I still didnot understand why length of the resulting tube depends
from quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place
an item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I need to read the sweep and skin functions you mentioned. What I want is - may be 5 different sections - path has only 5 points - radius at each point in the path - smoother transition from 1 section to another Function should develop a polyhedron On Thu, 13 Oct, 2022, 8:07 am Adrian Mariano, <avm4@cornell.edu> wrote: > So you're suggesting the following: Given a path, a list of N points on > the path, and N sections to be located at those points, create a polyhedron > that passes through the sections in a "smooth" manner. The skin() module > does this, except it doesn't attempt to satisfy any smoothness > constraints. From my experience in writing skin() I can say it will be > very hard to be fully general. You probably want to require that each > section has the same number of points and that point 0 matches to point 0 > on each section. (See the BOSL2 skin documentation for various attempts to > address the cases when these requirements fail.) > > To satisfy a smoothness constraint seems challenging. You can construct a > bezier that passes through all the corresponding points of the sections, > perhaps? It won't necessarily have anything to do with the path, though, > and could produce asymmetric results for symmetric inputs, I suspect. That > is, controlling the direction in which it curves to create smoothness might > be difficult. > > On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar < > sprabhakar2006@gmail.com> wrote: > >> The application should have capability to >> 1. Place different sections (not necessarily circular, it can be a >> combination) at defined location in a path >> 2. smoother transition of sections with no sharp corners >> 3.Path can be in different planes >> 4. Maybe input 5 sections and 5 index locations in a path (max) >> 5.Simple for enduser >> >> >> On Thu, 13 Oct 2022, 07:30 Adrian Mariano, <avm4@cornell.edu> wrote: >> >>> What exactly are you envisioning? In BOSL2 I have sweep() which is >>> extremely general and can do this, though because of generality, it is also >>> more difficult to use. I was pondering if I should add scaling to the >>> regular path_sweep() module. I think this would be an easy addition. >>> >>> On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar < >>> sprabhakar2006@gmail.com> wrote: >>> >>>> I really find this as an interesting application. >>>> There should be some generic solution to such modeling applications. >>>> [image: Screenshot 2022-10-13 at 6.48.54 AM.png] >>>> >>>> On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> wrote: >>>> >>>>> So actually when I said n+1 it should have been n-1. When I wrote the >>>>> replacement code I followed your code. In your code you have this loop: >>>>> >>>>> for (i=[1:1:n-1]){ >>>>> diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); >>>>> diam = path_pos_from_start(pb,i*bl/n,closed=false); >>>>> bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] >>>>> ); >>>>> bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], >>>>> diam[1]); >>>>> hull(){ >>>>> path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) >>>>> rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); >>>>> path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) >>>>> rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); >>>>> } >>>>> } >>>>> >>>>> The max value of i is n-1. When you calculate diam you do it at >>>>> i*bl/n whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). >>>>> That means that you will omit the last sample. It seems odd, but I was >>>>> just duplicating the functionality of your code. As I have said, there are >>>>> many things that look strange, but only you can say if they are in fact >>>>> wrong. It does seem like in most places, the incorrect looking code only >>>>> makes a small difference in the outcome, like things shift around by less >>>>> than 1 unit. >>>>> >>>>> If you want to duplicate the current functionality I still think >>>>> path_cut is the best way to do it: >>>>> >>>>> module place_item_on_skin(l,angle){ >>>>> pathlist = path_cut(pb,l,closed=false); >>>>> pt = last(pathlist[0]); >>>>> echo(equal=pt[1],pl-l); >>>>> color("lightblue") path_spread(p, 1,1,pt[1]) >>>>> rotate([90,0,0])translate([0,0,pt[0]/2])children(0); >>>>> } >>>>> >>>>> Attached is a modified version of neck1200.scad that doesn't depend on >>>>> the obsolete function. Also attached is a version that uses sweep() the >>>>> way I would have coded this model. >>>>> >>>>> >>>>> On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> >>>>> wrote: >>>>> >>>>>> I have run your code and I have read it through, and as I have said >>>>>> many times it appears WRONG. Whether I am right about that depends on the >>>>>> exact meaning of pb. >>>>>> >>>>>> p = [[0,0],[1,5],[2,100]]; >>>>>> echo(path_pos_from_start(p,path_length(p)/2)); >>>>>> echo(lookup(1,p)); >>>>>> >>>>>> The output is >>>>>> >>>>>> ECHO: [1, 0.473165] >>>>>> ECHO: 5 >>>>>> >>>>>> So please tell me the intention. What do the entries in pb mean >>>>>> exactly? I think the reason you don't end where you expect is probably >>>>>> that you divided by n instead of n+1 in the loop. >>>>>> >>>>>> When you use the command place_item(L) is the intention that the item >>>>>> is placed at length L from the end of your model? Or is the intent that >>>>>> the item is placed somewhere else, approximately L but not exactly L? Your >>>>>> existing code does the second thing, not the first one. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >>>>>> discuss@lists.openscad.org> wrote: >>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>> discuss@lists.openscad.org> >>>>>>> Cc: >>>>>>> Bcc: >>>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>> I tried your idea but don't get 0.47. It still seems linear >>>>>>> interpolatetion here. >>>>>>> Please run my code with old paths.scad I attached. It's working code. >>>>>>> >>>>>>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian >>>>>>> Mariano <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>>>>>> >>>>>>> >>>>>>> *When you invoke path_pos_from_start() on the pb variable you are >>>>>>> treating pb as a curve in 2d. But from reading your code, it appears that >>>>>>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>>>>>> as a function of path length along the curve defined by p. I am somewhat >>>>>>> guessing here based on the code, but if that is true, then treating it like >>>>>>> a curve in 2D will give incorrect results. If we have a simple example:* >>>>>>> >>>>>>> >>>>>>> *p=* >>>>>>> *[[0,0],* >>>>>>> * [1,5],* >>>>>>> * [2,100]]* >>>>>>> >>>>>>> *where the first entry gives position and the second entry gives >>>>>>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>>>>>> if you use the method implemented in the neck1000 code which is based on >>>>>>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>>>>>> of 0.47 instead of 5. You can't assume that the functions will magically >>>>>>> produce the right answer even if you ask them to do the wrong thing!* >>>>>>> >>>>>>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>>>>>> path_cut) do is not the same as interpolating a lookup table. A correct >>>>>>> way to get that value would be lookup(1,p); I think you can replace every >>>>>>> call of path_pos_from_start with lookup and then you won't need the old >>>>>>> function. * >>>>>>> >>>>>>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>>>>>> discuss@lists.openscad.org> wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>> discuss@lists.openscad.org> >>>>>>> Cc: >>>>>>> Bcc: >>>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>> As I understand interpolation is done automatically inside the BOLS2 >>>>>>> functions. Dont know what exactly method is implemented. >>>>>>> You set number of equally spaced interpolation points only for >>>>>>> generating tube. It does not depend from how input path set. >>>>>>> So you can find a point at given length. >>>>>>> For tangent/normal rotating items I set rotate_children=true >>>>>>> >>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano < >>>>>>> avm4@cornell.edu> wrote: >>>>>>> >>>>>>> >>>>>>> I examined neck1200.scad. The problem reported about errors >>>>>>> compiling is fixed by removing the "use" statements. >>>>>>> >>>>>>> However, I'm a little confused about the intent of the neck1200 >>>>>>> code. There is a list of points in 2d described as "diameter". It appears >>>>>>> that maybe the second value is the position and the first value the >>>>>>> diameter at that position. This point list is then operated on using >>>>>>> path_pos_from_start. But that doesn't make sense, because the data is not >>>>>>> actually a path in 2d. You should be interpolating just on the second >>>>>>> coordinate to find position. I would probably do this with lookup()----but >>>>>>> the coordinates would need to be swapped first. >>>>>>> >>>>>>> The code for creating the actual shape is a chain hull of >>>>>>> cylinders. I would do this with sweep. I would use path_sweep with the >>>>>>> transforms=true option to get a list of transform matrices. I would apply >>>>>>> the scales to those and then invoke sweep(). >>>>>>> >>>>>>> For putting objects on the surface you should be able to do it with >>>>>>> just a call to path_spread(), I think. Note that path_cut is not a drop in >>>>>>> replacement for path_pos_from_start(). The old function returned an index >>>>>>> into the path plus a fraction along the next path segment. The new >>>>>>> function takes a list of cut points and returns all the paths cut at those >>>>>>> points, so you can then extract the ends that you need directly. >>>>>>> >>>>>>> Docs for path_cut: >>>>>>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>>>>>> >>>>>>> If you just want the code to work, here's the old function: >>>>>>> >>>>>>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>>>>>> let (lp = len(path)) >>>>>>> _i >= lp - (closed?0:1)? undef : >>>>>>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>>>>>> _d+l <= length? >>>>>>> path_pos_from_start(path,length,closed,_d+l,_i+1) : >>>>>>> [_i, (length-_d)/l]; >>>>>>> >>>>>>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>>>>>> discuss@lists.openscad.org> wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>> discuss@lists.openscad.org> >>>>>>> Cc: >>>>>>> Bcc: >>>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>> Direct replacement does not work. see attachment >>>>>>> >>>>>>> More info: >>>>>>> To reverse engineering saxophones for fdm 3dprinting I use two >>>>>>> curve approach. >>>>>>> One curve is path to "extrude" and second is - diameters along this >>>>>>> path. >>>>>>> After bulding tube I place toneholes, posts and etc, defined by >>>>>>> length from top of tube. >>>>>>> So I need function to return diameter at given length and angle to >>>>>>> rotate item I want to place >>>>>>> I draw curve manually in MOI3D then save as polyline dxf then >>>>>>> convert to openscad polyline with dxfwread.exe tool. >>>>>>> I almost solved all the above, but have a feel that there is more >>>>>>> elegant solution. >>>>>>> >>>>>>> Equal spacing along the curve is overkill on straight segments. >>>>>>> BSpline examples in this maillist seems to be useful but I didnot realize >>>>>>> how to implement. >>>>>>> I still didnot understand why length of the resulting tube depends >>>>>>> from quantization number and how to avoid its changing. >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>> >>>>>>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>>>>>> avm4@cornell.edu> wrote: >>>>>>> >>>>>>> >>>>>>> I believe that path_pos_from_start was eliminated because it was >>>>>>> redundant with path_cut. Can path_cut do what you need? >>>>>>> >>>>>>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>>>>>> discuss@lists.openscad.org> wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>> Cc: >>>>>>> Bcc: >>>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>>> I use this function in BOLS2 from 2020 for finding point to place >>>>>>> an item on curved tube. >>>>>>> It is absent in newer BOLS2. >>>>>>> What I need to use insteed ? >>>>>>> >>>>>>> SY, Yuri >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> Bcc: >>>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>> discuss@lists.openscad.org> >>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> Bcc: >>>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>> discuss@lists.openscad.org> >>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> Bcc: >>>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>> discuss@lists.openscad.org> >>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>> Bcc: >>>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Thu, Oct 13, 2022 3:05 AM

So if you start with a path that has 5 points you could smooth the path
such that it still passes through the specified points.  (There is a
path_smooth function in BOSL2 that uses beziers to do this.)  Then you
could use a path sweep method to create the polyhedron.  That would mean
the polygon sections are normal to the path and congruent.  Adding scaling
is easy.  But making the sections arbitrary I think creates more
complication.  If you assume equal length polygons that map index 0 to
index 0 then you could linearly interpret based on arc length along the
path.  I think that would work.

Note that path_sweep and skin in BOSL2 are both complicated but for
different reasons.  For path_sweep the sections are all congruent, and they
are given just as a single 2d polygon which is supposed to be placed on the
path, perpendicular to the path.  The problem is that this rule is
ambiguous about rotation of the section around the path tangent direction
(twisting).  So the complications there all have to do with ways to define
how the sections twist, or to try to limit twist.

For skin you provide a list of arbitrary polygons in 3-space.  The
challenge is to determine how to link up their points, since arbitrary
polygons may have different vertex count, and even if the count is the same
you need to make a decision about which point vertex 0 from the first shape
should map to in the next shape.

On Wed, Oct 12, 2022 at 10:49 PM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

I need to read the sweep and skin functions you mentioned.
What I want is

  • may be 5 different sections
  • path has only 5 points
  • radius at each point in the path
  • smoother transition from 1 section to another

Function should develop a polyhedron

On Thu, 13 Oct, 2022, 8:07 am Adrian Mariano, avm4@cornell.edu wrote:

So you're suggesting the following:  Given a path, a list of N points on
the path, and N sections to be located at those points, create a polyhedron
that passes through the sections in a "smooth" manner.  The skin() module
does this, except it doesn't attempt to satisfy any smoothness
constraints.  From my experience in writing skin() I can say it will be
very hard to be fully general.  You probably want to require that each
section has the same number of points and that point 0 matches to point 0
on each section.  (See the BOSL2 skin documentation for various attempts to
address the cases when these requirements fail.)

To satisfy a smoothness constraint seems challenging.  You can construct
a bezier that passes through all the corresponding points of the sections,
perhaps?  It won't necessarily have anything to do with the path, though,
and could produce asymmetric results for symmetric inputs, I suspect.  That
is, controlling the direction in which it curves to create smoothness might
be difficult.

On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

The application should have capability to

  1. Place different sections (not necessarily circular, it can be a
    combination) at defined location in a path
  2. smoother transition of sections with no sharp corners
    3.Path can be in different planes
  3. Maybe input 5 sections and 5 index locations in a path (max)
    5.Simple for enduser

On Thu, 13 Oct 2022, 07:30 Adrian Mariano, avm4@cornell.edu wrote:

What exactly are you envisioning?  In BOSL2 I have sweep() which is
extremely general and can do this, though because of generality, it is also
more difficult to use.  I was pondering if I should add scaling to the
regular path_sweep() module.  I think this would be an easy addition.

On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu wrote:

So actually when I said n+1 it should have been n-1.  When I wrote
the replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],  diam0[1]
);
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],
diam[1]);
hull(){
path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at
i*bl/n whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).
That means that you will omit the last sample.  It seems odd, but I was
just duplicating the functionality of your code.  As I have said, there are
many things that look strange, but only you can say if they are in fact
wrong.  It does seem like in most places, the incorrect looking code only
makes a small difference in the outcome, like things shift around by less
than 1 unit.

If you want to duplicate the current functionality I still think
path_cut is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend
on the obsolete function.  Also attached is a version that uses sweep() the
way I would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu
wrote:

I have run your code and I have read it through, and as I have said
many times it appears WRONG.  Whether I am right about that depends on the
exact meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the
item is placed at length L from the end of your model?  Or is the intent
that the item is placed somewhere else, approximately L but not exactly L?
Your existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working
code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the
BOLS2 functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano
avm4@cornell.edu wrote:

I examined neck1200.scad.  The problem reported about errors
compiling is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200
code.  There is a list of points in 2d described as "diameter".  It appears
that maybe the second value is the position and the first value the
diameter at that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of
cylinders.  I would do this with sweep.  I would use path_sweep with the
transforms=true option to get a list of transform matrices.  I would apply
the scales to those and then invoke sweep().

For putting objects on the surface you should be able to do it with
just a call to path_spread(), I think.  Note that path_cut is not a drop in
replacement for path_pos_from_start().  The old function returned an index
into the path plus a fraction along the next path segment.  The new
function takes a list of cut points and returns all the paths cut at those
points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length?
path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two
curve approach.
One curve is path to "extrude" and second is - diameters along this
path.
After bulding tube I place toneholes, posts and etc, defined by
length from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then
convert to openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments.
BSpline examples in this maillist seems to be useful but I didnot realize
how to implement.
I still didnot understand why length of the resulting tube depends
from quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place
an item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

So if you start with a path that has 5 points you could smooth the path such that it still passes through the specified points. (There is a path_smooth function in BOSL2 that uses beziers to do this.) Then you could use a path sweep method to create the polyhedron. That would mean the polygon sections are normal to the path and congruent. Adding scaling is easy. But making the sections arbitrary I think creates more complication. If you assume equal length polygons that map index 0 to index 0 then you could linearly interpret based on arc length along the path. I think that would work. Note that path_sweep and skin in BOSL2 are both complicated but for different reasons. For path_sweep the sections are all congruent, and they are given just as a single 2d polygon which is supposed to be placed on the path, perpendicular to the path. The problem is that this rule is ambiguous about rotation of the section around the path tangent direction (twisting). So the complications there all have to do with ways to define how the sections twist, or to try to limit twist. For skin you provide a list of arbitrary polygons in 3-space. The challenge is to determine how to link up their points, since arbitrary polygons may have different vertex count, and even if the count is the same you need to make a decision about which point vertex 0 from the first shape should map to in the next shape. On Wed, Oct 12, 2022 at 10:49 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > I need to read the sweep and skin functions you mentioned. > What I want is > - may be 5 different sections > - path has only 5 points > - radius at each point in the path > - smoother transition from 1 section to another > > Function should develop a polyhedron > > > On Thu, 13 Oct, 2022, 8:07 am Adrian Mariano, <avm4@cornell.edu> wrote: > >> So you're suggesting the following: Given a path, a list of N points on >> the path, and N sections to be located at those points, create a polyhedron >> that passes through the sections in a "smooth" manner. The skin() module >> does this, except it doesn't attempt to satisfy any smoothness >> constraints. From my experience in writing skin() I can say it will be >> very hard to be fully general. You probably want to require that each >> section has the same number of points and that point 0 matches to point 0 >> on each section. (See the BOSL2 skin documentation for various attempts to >> address the cases when these requirements fail.) >> >> To satisfy a smoothness constraint seems challenging. You can construct >> a bezier that passes through all the corresponding points of the sections, >> perhaps? It won't necessarily have anything to do with the path, though, >> and could produce asymmetric results for symmetric inputs, I suspect. That >> is, controlling the direction in which it curves to create smoothness might >> be difficult. >> >> On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar < >> sprabhakar2006@gmail.com> wrote: >> >>> The application should have capability to >>> 1. Place different sections (not necessarily circular, it can be a >>> combination) at defined location in a path >>> 2. smoother transition of sections with no sharp corners >>> 3.Path can be in different planes >>> 4. Maybe input 5 sections and 5 index locations in a path (max) >>> 5.Simple for enduser >>> >>> >>> On Thu, 13 Oct 2022, 07:30 Adrian Mariano, <avm4@cornell.edu> wrote: >>> >>>> What exactly are you envisioning? In BOSL2 I have sweep() which is >>>> extremely general and can do this, though because of generality, it is also >>>> more difficult to use. I was pondering if I should add scaling to the >>>> regular path_sweep() module. I think this would be an easy addition. >>>> >>>> On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar < >>>> sprabhakar2006@gmail.com> wrote: >>>> >>>>> I really find this as an interesting application. >>>>> There should be some generic solution to such modeling applications. >>>>> [image: Screenshot 2022-10-13 at 6.48.54 AM.png] >>>>> >>>>> On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> wrote: >>>>> >>>>>> So actually when I said n+1 it should have been n-1. When I wrote >>>>>> the replacement code I followed your code. In your code you have this loop: >>>>>> >>>>>> for (i=[1:1:n-1]){ >>>>>> diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); >>>>>> diam = path_pos_from_start(pb,i*bl/n,closed=false); >>>>>> bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], diam0[1] >>>>>> ); >>>>>> bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], >>>>>> diam[1]); >>>>>> hull(){ >>>>>> path_spread(p, 1,1,bt0[1], rotate_children=true,closed=false) >>>>>> rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); >>>>>> path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) >>>>>> rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); >>>>>> } >>>>>> } >>>>>> >>>>>> The max value of i is n-1. When you calculate diam you do it at >>>>>> i*bl/n whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). >>>>>> That means that you will omit the last sample. It seems odd, but I was >>>>>> just duplicating the functionality of your code. As I have said, there are >>>>>> many things that look strange, but only you can say if they are in fact >>>>>> wrong. It does seem like in most places, the incorrect looking code only >>>>>> makes a small difference in the outcome, like things shift around by less >>>>>> than 1 unit. >>>>>> >>>>>> If you want to duplicate the current functionality I still think >>>>>> path_cut is the best way to do it: >>>>>> >>>>>> module place_item_on_skin(l,angle){ >>>>>> pathlist = path_cut(pb,l,closed=false); >>>>>> pt = last(pathlist[0]); >>>>>> echo(equal=pt[1],pl-l); >>>>>> color("lightblue") path_spread(p, 1,1,pt[1]) >>>>>> rotate([90,0,0])translate([0,0,pt[0]/2])children(0); >>>>>> } >>>>>> >>>>>> Attached is a modified version of neck1200.scad that doesn't depend >>>>>> on the obsolete function. Also attached is a version that uses sweep() the >>>>>> way I would have coded this model. >>>>>> >>>>>> >>>>>> On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> >>>>>> wrote: >>>>>> >>>>>>> I have run your code and I have read it through, and as I have said >>>>>>> many times it appears WRONG. Whether I am right about that depends on the >>>>>>> exact meaning of pb. >>>>>>> >>>>>>> p = [[0,0],[1,5],[2,100]]; >>>>>>> echo(path_pos_from_start(p,path_length(p)/2)); >>>>>>> echo(lookup(1,p)); >>>>>>> >>>>>>> The output is >>>>>>> >>>>>>> ECHO: [1, 0.473165] >>>>>>> ECHO: 5 >>>>>>> >>>>>>> So please tell me the intention. What do the entries in pb mean >>>>>>> exactly? I think the reason you don't end where you expect is probably >>>>>>> that you divided by n instead of n+1 in the loop. >>>>>>> >>>>>>> When you use the command place_item(L) is the intention that the >>>>>>> item is placed at length L from the end of your model? Or is the intent >>>>>>> that the item is placed somewhere else, approximately L but not exactly L? >>>>>>> Your existing code does the second thing, not the first one. >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >>>>>>> discuss@lists.openscad.org> wrote: >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>> discuss@lists.openscad.org> >>>>>>>> Cc: >>>>>>>> Bcc: >>>>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> I tried your idea but don't get 0.47. It still seems linear >>>>>>>> interpolatetion here. >>>>>>>> Please run my code with old paths.scad I attached. It's working >>>>>>>> code. >>>>>>>> >>>>>>>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian >>>>>>>> Mariano <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>>>>>>> >>>>>>>> >>>>>>>> *When you invoke path_pos_from_start() on the pb variable you are >>>>>>>> treating pb as a curve in 2d. But from reading your code, it appears that >>>>>>>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>>>>>>> as a function of path length along the curve defined by p. I am somewhat >>>>>>>> guessing here based on the code, but if that is true, then treating it like >>>>>>>> a curve in 2D will give incorrect results. If we have a simple example:* >>>>>>>> >>>>>>>> >>>>>>>> *p=* >>>>>>>> *[[0,0],* >>>>>>>> * [1,5],* >>>>>>>> * [2,100]]* >>>>>>>> >>>>>>>> *where the first entry gives position and the second entry gives >>>>>>>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>>>>>>> if you use the method implemented in the neck1000 code which is based on >>>>>>>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>>>>>>> of 0.47 instead of 5. You can't assume that the functions will magically >>>>>>>> produce the right answer even if you ask them to do the wrong thing!* >>>>>>>> >>>>>>>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>>>>>>> path_cut) do is not the same as interpolating a lookup table. A correct >>>>>>>> way to get that value would be lookup(1,p); I think you can replace every >>>>>>>> call of path_pos_from_start with lookup and then you won't need the old >>>>>>>> function. * >>>>>>>> >>>>>>>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>>>>>>> discuss@lists.openscad.org> wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>> discuss@lists.openscad.org> >>>>>>>> Cc: >>>>>>>> Bcc: >>>>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> As I understand interpolation is done automatically inside the >>>>>>>> BOLS2 functions. Dont know what exactly method is implemented. >>>>>>>> You set number of equally spaced interpolation points only for >>>>>>>> generating tube. It does not depend from how input path set. >>>>>>>> So you can find a point at given length. >>>>>>>> For tangent/normal rotating items I set rotate_children=true >>>>>>>> >>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian Mariano >>>>>>>> <avm4@cornell.edu> wrote: >>>>>>>> >>>>>>>> >>>>>>>> I examined neck1200.scad. The problem reported about errors >>>>>>>> compiling is fixed by removing the "use" statements. >>>>>>>> >>>>>>>> However, I'm a little confused about the intent of the neck1200 >>>>>>>> code. There is a list of points in 2d described as "diameter". It appears >>>>>>>> that maybe the second value is the position and the first value the >>>>>>>> diameter at that position. This point list is then operated on using >>>>>>>> path_pos_from_start. But that doesn't make sense, because the data is not >>>>>>>> actually a path in 2d. You should be interpolating just on the second >>>>>>>> coordinate to find position. I would probably do this with lookup()----but >>>>>>>> the coordinates would need to be swapped first. >>>>>>>> >>>>>>>> The code for creating the actual shape is a chain hull of >>>>>>>> cylinders. I would do this with sweep. I would use path_sweep with the >>>>>>>> transforms=true option to get a list of transform matrices. I would apply >>>>>>>> the scales to those and then invoke sweep(). >>>>>>>> >>>>>>>> For putting objects on the surface you should be able to do it with >>>>>>>> just a call to path_spread(), I think. Note that path_cut is not a drop in >>>>>>>> replacement for path_pos_from_start(). The old function returned an index >>>>>>>> into the path plus a fraction along the next path segment. The new >>>>>>>> function takes a list of cut points and returns all the paths cut at those >>>>>>>> points, so you can then extract the ends that you need directly. >>>>>>>> >>>>>>>> Docs for path_cut: >>>>>>>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>>>>>>> >>>>>>>> If you just want the code to work, here's the old function: >>>>>>>> >>>>>>>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>>>>>>> let (lp = len(path)) >>>>>>>> _i >= lp - (closed?0:1)? undef : >>>>>>>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>>>>>>> _d+l <= length? >>>>>>>> path_pos_from_start(path,length,closed,_d+l,_i+1) : >>>>>>>> [_i, (length-_d)/l]; >>>>>>>> >>>>>>>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>>>>>>> discuss@lists.openscad.org> wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>> discuss@lists.openscad.org> >>>>>>>> Cc: >>>>>>>> Bcc: >>>>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> Direct replacement does not work. see attachment >>>>>>>> >>>>>>>> More info: >>>>>>>> To reverse engineering saxophones for fdm 3dprinting I use two >>>>>>>> curve approach. >>>>>>>> One curve is path to "extrude" and second is - diameters along this >>>>>>>> path. >>>>>>>> After bulding tube I place toneholes, posts and etc, defined by >>>>>>>> length from top of tube. >>>>>>>> So I need function to return diameter at given length and angle to >>>>>>>> rotate item I want to place >>>>>>>> I draw curve manually in MOI3D then save as polyline dxf then >>>>>>>> convert to openscad polyline with dxfwread.exe tool. >>>>>>>> I almost solved all the above, but have a feel that there is more >>>>>>>> elegant solution. >>>>>>>> >>>>>>>> Equal spacing along the curve is overkill on straight segments. >>>>>>>> BSpline examples in this maillist seems to be useful but I didnot realize >>>>>>>> how to implement. >>>>>>>> I still didnot understand why length of the resulting tube depends >>>>>>>> from quantization number and how to avoid its changing. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>> >>>>>>>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>>>>>>> avm4@cornell.edu> wrote: >>>>>>>> >>>>>>>> >>>>>>>> I believe that path_pos_from_start was eliminated because it was >>>>>>>> redundant with path_cut. Can path_cut do what you need? >>>>>>>> >>>>>>>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>>>>>>> discuss@lists.openscad.org> wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>> Cc: >>>>>>>> Bcc: >>>>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> I use this function in BOLS2 from 2020 for finding point to place >>>>>>>> an item on curved tube. >>>>>>>> It is absent in newer BOLS2. >>>>>>>> What I need to use insteed ? >>>>>>>> >>>>>>>> SY, Yuri >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> Bcc: >>>>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> _______________________________________________ >>>>>>>> OpenSCAD mailing list >>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> OpenSCAD mailing list >>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>> discuss@lists.openscad.org> >>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> Bcc: >>>>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> _______________________________________________ >>>>>>>> OpenSCAD mailing list >>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> OpenSCAD mailing list >>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>> discuss@lists.openscad.org> >>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> Bcc: >>>>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> _______________________________________________ >>>>>>>> OpenSCAD mailing list >>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> OpenSCAD mailing list >>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> ---------- Forwarded message ---------- >>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>> discuss@lists.openscad.org> >>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>> Bcc: >>>>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>> _______________________________________________ >>>>>>>> OpenSCAD mailing list >>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>> >>>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Thu, Oct 13, 2022 3:15 AM

I will also think about this.
Right now I have to rush, getting late for office.
bye

On Thu, 13 Oct 2022, 08:36 Adrian Mariano, avm4@cornell.edu wrote:

So if you start with a path that has 5 points you could smooth the path
such that it still passes through the specified points.  (There is a
path_smooth function in BOSL2 that uses beziers to do this.)  Then you
could use a path sweep method to create the polyhedron.  That would mean
the polygon sections are normal to the path and congruent.  Adding scaling
is easy.  But making the sections arbitrary I think creates more
complication.  If you assume equal length polygons that map index 0 to
index 0 then you could linearly interpret based on arc length along the
path.  I think that would work.

Note that path_sweep and skin in BOSL2 are both complicated but for
different reasons.  For path_sweep the sections are all congruent, and they
are given just as a single 2d polygon which is supposed to be placed on the
path, perpendicular to the path.  The problem is that this rule is
ambiguous about rotation of the section around the path tangent direction
(twisting).  So the complications there all have to do with ways to define
how the sections twist, or to try to limit twist.

For skin you provide a list of arbitrary polygons in 3-space.  The
challenge is to determine how to link up their points, since arbitrary
polygons may have different vertex count, and even if the count is the same
you need to make a decision about which point vertex 0 from the first shape
should map to in the next shape.

On Wed, Oct 12, 2022 at 10:49 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

I need to read the sweep and skin functions you mentioned.
What I want is

  • may be 5 different sections
  • path has only 5 points
  • radius at each point in the path
  • smoother transition from 1 section to another

Function should develop a polyhedron

On Thu, 13 Oct, 2022, 8:07 am Adrian Mariano, avm4@cornell.edu wrote:

So you're suggesting the following:  Given a path, a list of N points on
the path, and N sections to be located at those points, create a polyhedron
that passes through the sections in a "smooth" manner.  The skin() module
does this, except it doesn't attempt to satisfy any smoothness
constraints.  From my experience in writing skin() I can say it will be
very hard to be fully general.  You probably want to require that each
section has the same number of points and that point 0 matches to point 0
on each section.  (See the BOSL2 skin documentation for various attempts to
address the cases when these requirements fail.)

To satisfy a smoothness constraint seems challenging.  You can construct
a bezier that passes through all the corresponding points of the sections,
perhaps?  It won't necessarily have anything to do with the path, though,
and could produce asymmetric results for symmetric inputs, I suspect.  That
is, controlling the direction in which it curves to create smoothness might
be difficult.

On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

The application should have capability to

  1. Place different sections (not necessarily circular, it can be a
    combination) at defined location in a path
  2. smoother transition of sections with no sharp corners
    3.Path can be in different planes
  3. Maybe input 5 sections and 5 index locations in a path (max)
    5.Simple for enduser

On Thu, 13 Oct 2022, 07:30 Adrian Mariano, avm4@cornell.edu wrote:

What exactly are you envisioning?  In BOSL2 I have sweep() which is
extremely general and can do this, though because of generality, it is also
more difficult to use.  I was pondering if I should add scaling to the
regular path_sweep() module.  I think this would be an easy addition.

On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

I really find this as an interesting application.
There should be some generic solution to such modeling applications.
[image: Screenshot 2022-10-13 at 6.48.54 AM.png]

On Thu, 13 Oct 2022 at 04:11, Adrian Mariano avm4@cornell.edu
wrote:

So actually when I said n+1 it should have been n-1.  When I wrote
the replacement code I followed your code.  In your code you have this loop:

for (i=[1:1:n-1]){
diam0= path_pos_from_start(pb,(i-1)bl/n,closed=false);
diam = path_pos_from_start(pb,i
bl/n,closed=false);
bt0 = lerp(  pb[diam0[0]],  pb[(diam0[0]+1)%len(pb)],
diam0[1] );
bt  = lerp(  pb[diam[0]],    pb[(diam[0]+1)%len(pb)],
diam[1]);
hull(){
path_spread(p, 1,1,bt0[1],
rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50);
path_spread(p, 1,1,bt[1], rotate_children=true,closed=false)
rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50);
}
}

The max value of i is n-1.  When you calculate diam you do it at
i*bl/n whose max value will be (n-1)*bl/n, or (n-1)/n  * path_length(pb).
That means that you will omit the last sample.  It seems odd, but I was
just duplicating the functionality of your code.  As I have said, there are
many things that look strange, but only you can say if they are in fact
wrong.  It does seem like in most places, the incorrect looking code only
makes a small difference in the outcome, like things shift around by less
than 1 unit.

If you want to duplicate the current functionality I still think
path_cut is the best way to do it:

module place_item_on_skin(l,angle){
pathlist = path_cut(pb,l,closed=false);
pt = last(pathlist[0]);
echo(equal=pt[1],pl-l);
color("lightblue") path_spread(p, 1,1,pt[1])
rotate([90,0,0])translate([0,0,pt[0]/2])children(0);
}

Attached is a modified version of neck1200.scad that doesn't depend
on the obsolete function.  Also attached is a version that uses sweep() the
way I would have coded this model.

On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano avm4@cornell.edu
wrote:

I have run your code and I have read it through, and as I have said
many times it appears WRONG.  Whether I am right about that depends on the
exact meaning of pb.

p = [[0,0],[1,5],[2,100]];
echo(path_pos_from_start(p,path_length(p)/2));
echo(lookup(1,p));

The output is

ECHO: [1, 0.473165]
ECHO: 5

So please tell me the intention.  What do the entries in pb mean
exactly?  I think the reason you don't end where you expect is probably
that you divided by n instead of n+1 in the loop.

When you use the command place_item(L) is the intention that the
item is placed at length L from the end of your model?  Or is the intent
that the item is placed somewhere else, approximately L but not exactly L?
Your existing code does the second thing, not the first one.

On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
I tried your idea but don't get 0.47. It still seems linear
interpolatetion here.
Please run my code with old paths.scad I attached. It's working
code.

When you invoke path_pos_from_start() on the pb variable you are
treating pb as a curve in 2d.  But from reading your code, it appears that
pb is NOT a curve in 2d.  It is a lookup table that specifies the diameter
as a function of path length along the curve defined by p.  I am somewhat
guessing here based on the code, but if that is true, then treating it like
a curve in 2D will give incorrect results.  If we have a simple example:

p=
[[0,0],

  • [1,5],*
  • [2,100]]*

where the first entry gives position and the second entry gives
diameter then the correct diameter at the midpoint, position 1, is 5, but
if you use the method implemented in the neck1000 code which is based on
path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter
of 0.47 instead of 5.  You can't assume that the functions will magically
produce the right answer even if you ask them to do the wrong thing!

*Interpolating a 2d curve, which is what path_pos_from_start (and
path_cut) do is not the same as interpolating a lookup table.  A correct
way to get that value would be lookup(1,p);  I think you can replace every
call of path_pos_from_start with lookup and then you won't need the old
function.  *

On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
As I understand interpolation is done automatically inside the
BOLS2 functions.  Dont know what exactly method is implemented.
You set number of equally spaced interpolation points only for
generating tube. It does not depend from how input path set.
So you can find a point at given length.
For tangent/normal rotating items I set rotate_children=true

On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian
Mariano avm4@cornell.edu wrote:

I examined neck1200.scad.  The problem reported about errors
compiling is fixed by removing the "use" statements.

However, I'm a little confused about the intent of the neck1200
code.  There is a list of points in 2d described as "diameter".  It appears
that maybe the second value is the position and the first value the
diameter at that position.  This point list is then operated on using
path_pos_from_start.  But that doesn't make sense, because the data is not
actually a path in 2d.  You should be interpolating just on the second
coordinate to find position.  I would probably do this with lookup()----but
the coordinates would need to be swapped first.

The code for creating the actual shape is a chain hull of
cylinders.  I would do this with sweep.  I would use path_sweep with the
transforms=true option to get a list of transform matrices.  I would apply
the scales to those and then invoke sweep().

For putting objects on the surface you should be able to do it
with just a call to path_spread(), I think.  Note that path_cut is not a
drop in replacement for path_pos_from_start().  The old function returned
an index into the path plus a fraction along the next path segment.  The
new function takes a list of cut points and returns all the paths cut at
those points, so you can then extract the ends that you need directly.

Docs for path_cut:
https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut

If you just want the code to work, here's the old function:

function path_pos_from_start(path,length,closed=false,_d=0,_i=0) =
let (lp = len(path))
_i >= lp - (closed?0:1)? undef :
let (l = norm(path[(_i+1)%lp]-path[_i]))
_d+l <= length?
path_pos_from_start(path,length,closed,_d+l,_i+1) :
[_i, (length-_d)/l];

On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc:
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Direct replacement does not work. see attachment

More info:
To reverse engineering saxophones for fdm 3dprinting  I use two
curve approach.
One curve is path to "extrude" and second is - diameters along
this path.
After bulding tube I place toneholes, posts and etc, defined by
length from top of tube.
So I need function to return diameter at given length and angle to
rotate item I want to place
I draw curve manually in MOI3D then save as polyline dxf then
convert to openscad polyline with dxfwread.exe tool.
I almost solved all the above, but have a feel that there is more
elegant solution.

Equal spacing along the curve is overkill on straight segments.
BSpline examples in this maillist seems to be useful but I didnot realize
how to implement.
I still didnot understand why length of the resulting tube depends
from quantization number and how to avoid its changing.

On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano <
avm4@cornell.edu> wrote:

I believe that path_pos_from_start was eliminated because it was
redundant with path_cut.  Can path_cut do what you need?

On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss <
discuss@lists.openscad.org> wrote:

---------- Forwarded message ----------
From: Mr Yura Volodin yur_vol@yahoo.com
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc:
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?
I use this function in BOLS2 from 2020 for finding point  to place
an item on curved tube.
It is absent in newer BOLS2.
What I need to use insteed ?

SY, Yuri

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: Mr Yura Volodin via Discuss discuss@lists.openscad.org
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC)
Subject: [OpenSCAD] Where is "path_pos_from_start"  in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

---------- Forwarded message ----------
From: Mr Yura Volodin via Discuss discuss@lists.openscad.org
To: OpenSCAD general discussion Mailing-list <
discuss@lists.openscad.org>
Cc: Mr Yura Volodin yur_vol@yahoo.com
Bcc:
Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I will also think about this. Right now I have to rush, getting late for office. bye On Thu, 13 Oct 2022, 08:36 Adrian Mariano, <avm4@cornell.edu> wrote: > So if you start with a path that has 5 points you could smooth the path > such that it still passes through the specified points. (There is a > path_smooth function in BOSL2 that uses beziers to do this.) Then you > could use a path sweep method to create the polyhedron. That would mean > the polygon sections are normal to the path and congruent. Adding scaling > is easy. But making the sections arbitrary I think creates more > complication. If you assume equal length polygons that map index 0 to > index 0 then you could linearly interpret based on arc length along the > path. I think that would work. > > Note that path_sweep and skin in BOSL2 are both complicated but for > different reasons. For path_sweep the sections are all congruent, and they > are given just as a single 2d polygon which is supposed to be placed on the > path, perpendicular to the path. The problem is that this rule is > ambiguous about rotation of the section around the path tangent direction > (twisting). So the complications there all have to do with ways to define > how the sections twist, or to try to limit twist. > > For skin you provide a list of arbitrary polygons in 3-space. The > challenge is to determine how to link up their points, since arbitrary > polygons may have different vertex count, and even if the count is the same > you need to make a decision about which point vertex 0 from the first shape > should map to in the next shape. > > On Wed, Oct 12, 2022 at 10:49 PM Sanjeev Prabhakar < > sprabhakar2006@gmail.com> wrote: > >> I need to read the sweep and skin functions you mentioned. >> What I want is >> - may be 5 different sections >> - path has only 5 points >> - radius at each point in the path >> - smoother transition from 1 section to another >> >> Function should develop a polyhedron >> >> >> On Thu, 13 Oct, 2022, 8:07 am Adrian Mariano, <avm4@cornell.edu> wrote: >> >>> So you're suggesting the following: Given a path, a list of N points on >>> the path, and N sections to be located at those points, create a polyhedron >>> that passes through the sections in a "smooth" manner. The skin() module >>> does this, except it doesn't attempt to satisfy any smoothness >>> constraints. From my experience in writing skin() I can say it will be >>> very hard to be fully general. You probably want to require that each >>> section has the same number of points and that point 0 matches to point 0 >>> on each section. (See the BOSL2 skin documentation for various attempts to >>> address the cases when these requirements fail.) >>> >>> To satisfy a smoothness constraint seems challenging. You can construct >>> a bezier that passes through all the corresponding points of the sections, >>> perhaps? It won't necessarily have anything to do with the path, though, >>> and could produce asymmetric results for symmetric inputs, I suspect. That >>> is, controlling the direction in which it curves to create smoothness might >>> be difficult. >>> >>> On Wed, Oct 12, 2022 at 10:16 PM Sanjeev Prabhakar < >>> sprabhakar2006@gmail.com> wrote: >>> >>>> The application should have capability to >>>> 1. Place different sections (not necessarily circular, it can be a >>>> combination) at defined location in a path >>>> 2. smoother transition of sections with no sharp corners >>>> 3.Path can be in different planes >>>> 4. Maybe input 5 sections and 5 index locations in a path (max) >>>> 5.Simple for enduser >>>> >>>> >>>> On Thu, 13 Oct 2022, 07:30 Adrian Mariano, <avm4@cornell.edu> wrote: >>>> >>>>> What exactly are you envisioning? In BOSL2 I have sweep() which is >>>>> extremely general and can do this, though because of generality, it is also >>>>> more difficult to use. I was pondering if I should add scaling to the >>>>> regular path_sweep() module. I think this would be an easy addition. >>>>> >>>>> On Wed, Oct 12, 2022 at 9:24 PM Sanjeev Prabhakar < >>>>> sprabhakar2006@gmail.com> wrote: >>>>> >>>>>> I really find this as an interesting application. >>>>>> There should be some generic solution to such modeling applications. >>>>>> [image: Screenshot 2022-10-13 at 6.48.54 AM.png] >>>>>> >>>>>> On Thu, 13 Oct 2022 at 04:11, Adrian Mariano <avm4@cornell.edu> >>>>>> wrote: >>>>>> >>>>>>> So actually when I said n+1 it should have been n-1. When I wrote >>>>>>> the replacement code I followed your code. In your code you have this loop: >>>>>>> >>>>>>> for (i=[1:1:n-1]){ >>>>>>> diam0= path_pos_from_start(pb,(i-1)*bl/n,closed=false); >>>>>>> diam = path_pos_from_start(pb,i*bl/n,closed=false); >>>>>>> bt0 = lerp( pb[diam0[0]], pb[(diam0[0]+1)%len(pb)], >>>>>>> diam0[1] ); >>>>>>> bt = lerp( pb[diam[0]], pb[(diam[0]+1)%len(pb)], >>>>>>> diam[1]); >>>>>>> hull(){ >>>>>>> path_spread(p, 1,1,bt0[1], >>>>>>> rotate_children=true,closed=false) >>>>>>> rotate(90,[0,1,0])cylinder(d=bt0[0]+w,h=0.1,$fn=50); >>>>>>> path_spread(p, 1,1,bt[1], rotate_children=true,closed=false) >>>>>>> rotate(90,[0,1,0])cylinder(d=bt[0]+w,h=0.1,$fn=50); >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> The max value of i is n-1. When you calculate diam you do it at >>>>>>> i*bl/n whose max value will be (n-1)*bl/n, or (n-1)/n * path_length(pb). >>>>>>> That means that you will omit the last sample. It seems odd, but I was >>>>>>> just duplicating the functionality of your code. As I have said, there are >>>>>>> many things that look strange, but only you can say if they are in fact >>>>>>> wrong. It does seem like in most places, the incorrect looking code only >>>>>>> makes a small difference in the outcome, like things shift around by less >>>>>>> than 1 unit. >>>>>>> >>>>>>> If you want to duplicate the current functionality I still think >>>>>>> path_cut is the best way to do it: >>>>>>> >>>>>>> module place_item_on_skin(l,angle){ >>>>>>> pathlist = path_cut(pb,l,closed=false); >>>>>>> pt = last(pathlist[0]); >>>>>>> echo(equal=pt[1],pl-l); >>>>>>> color("lightblue") path_spread(p, 1,1,pt[1]) >>>>>>> rotate([90,0,0])translate([0,0,pt[0]/2])children(0); >>>>>>> } >>>>>>> >>>>>>> Attached is a modified version of neck1200.scad that doesn't depend >>>>>>> on the obsolete function. Also attached is a version that uses sweep() the >>>>>>> way I would have coded this model. >>>>>>> >>>>>>> >>>>>>> On Wed, Oct 12, 2022 at 4:46 PM Adrian Mariano <avm4@cornell.edu> >>>>>>> wrote: >>>>>>> >>>>>>>> I have run your code and I have read it through, and as I have said >>>>>>>> many times it appears WRONG. Whether I am right about that depends on the >>>>>>>> exact meaning of pb. >>>>>>>> >>>>>>>> p = [[0,0],[1,5],[2,100]]; >>>>>>>> echo(path_pos_from_start(p,path_length(p)/2)); >>>>>>>> echo(lookup(1,p)); >>>>>>>> >>>>>>>> The output is >>>>>>>> >>>>>>>> ECHO: [1, 0.473165] >>>>>>>> ECHO: 5 >>>>>>>> >>>>>>>> So please tell me the intention. What do the entries in pb mean >>>>>>>> exactly? I think the reason you don't end where you expect is probably >>>>>>>> that you divided by n instead of n+1 in the loop. >>>>>>>> >>>>>>>> When you use the command place_item(L) is the intention that the >>>>>>>> item is placed at length L from the end of your model? Or is the intent >>>>>>>> that the item is placed somewhere else, approximately L but not exactly L? >>>>>>>> Your existing code does the second thing, not the first one. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Wed, Oct 12, 2022 at 8:05 AM Mr Yura Volodin via Discuss < >>>>>>>> discuss@lists.openscad.org> wrote: >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>>> discuss@lists.openscad.org> >>>>>>>>> Cc: >>>>>>>>> Bcc: >>>>>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> I tried your idea but don't get 0.47. It still seems linear >>>>>>>>> interpolatetion here. >>>>>>>>> Please run my code with old paths.scad I attached. It's working >>>>>>>>> code. >>>>>>>>> >>>>>>>>> * On Wednesday, October 12, 2022 at 01:47:51 PM GMT+3, Adrian >>>>>>>>> Mariano <avm4@cornell.edu <avm4@cornell.edu>> wrote: * >>>>>>>>> >>>>>>>>> >>>>>>>>> *When you invoke path_pos_from_start() on the pb variable you are >>>>>>>>> treating pb as a curve in 2d. But from reading your code, it appears that >>>>>>>>> pb is NOT a curve in 2d. It is a lookup table that specifies the diameter >>>>>>>>> as a function of path length along the curve defined by p. I am somewhat >>>>>>>>> guessing here based on the code, but if that is true, then treating it like >>>>>>>>> a curve in 2D will give incorrect results. If we have a simple example:* >>>>>>>>> >>>>>>>>> >>>>>>>>> *p=* >>>>>>>>> *[[0,0],* >>>>>>>>> * [1,5],* >>>>>>>>> * [2,100]]* >>>>>>>>> >>>>>>>>> *where the first entry gives position and the second entry gives >>>>>>>>> diameter then the correct diameter at the midpoint, position 1, is 5, but >>>>>>>>> if you use the method implemented in the neck1000 code which is based on >>>>>>>>> path length, so path_pos_from_start(p,path_length(p)/2) you get a diameter >>>>>>>>> of 0.47 instead of 5. You can't assume that the functions will magically >>>>>>>>> produce the right answer even if you ask them to do the wrong thing!* >>>>>>>>> >>>>>>>>> *Interpolating a 2d curve, which is what path_pos_from_start (and >>>>>>>>> path_cut) do is not the same as interpolating a lookup table. A correct >>>>>>>>> way to get that value would be lookup(1,p); I think you can replace every >>>>>>>>> call of path_pos_from_start with lookup and then you won't need the old >>>>>>>>> function. * >>>>>>>>> >>>>>>>>> On Wed, Oct 12, 2022 at 3:34 AM Mr Yura Volodin via Discuss < >>>>>>>>> discuss@lists.openscad.org> wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>>> discuss@lists.openscad.org> >>>>>>>>> Cc: >>>>>>>>> Bcc: >>>>>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> As I understand interpolation is done automatically inside the >>>>>>>>> BOLS2 functions. Dont know what exactly method is implemented. >>>>>>>>> You set number of equally spaced interpolation points only for >>>>>>>>> generating tube. It does not depend from how input path set. >>>>>>>>> So you can find a point at given length. >>>>>>>>> For tangent/normal rotating items I set rotate_children=true >>>>>>>>> >>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> On Wednesday, October 12, 2022 at 02:00:39 AM GMT+3, Adrian >>>>>>>>> Mariano <avm4@cornell.edu> wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> I examined neck1200.scad. The problem reported about errors >>>>>>>>> compiling is fixed by removing the "use" statements. >>>>>>>>> >>>>>>>>> However, I'm a little confused about the intent of the neck1200 >>>>>>>>> code. There is a list of points in 2d described as "diameter". It appears >>>>>>>>> that maybe the second value is the position and the first value the >>>>>>>>> diameter at that position. This point list is then operated on using >>>>>>>>> path_pos_from_start. But that doesn't make sense, because the data is not >>>>>>>>> actually a path in 2d. You should be interpolating just on the second >>>>>>>>> coordinate to find position. I would probably do this with lookup()----but >>>>>>>>> the coordinates would need to be swapped first. >>>>>>>>> >>>>>>>>> The code for creating the actual shape is a chain hull of >>>>>>>>> cylinders. I would do this with sweep. I would use path_sweep with the >>>>>>>>> transforms=true option to get a list of transform matrices. I would apply >>>>>>>>> the scales to those and then invoke sweep(). >>>>>>>>> >>>>>>>>> For putting objects on the surface you should be able to do it >>>>>>>>> with just a call to path_spread(), I think. Note that path_cut is not a >>>>>>>>> drop in replacement for path_pos_from_start(). The old function returned >>>>>>>>> an index into the path plus a fraction along the next path segment. The >>>>>>>>> new function takes a list of cut points and returns all the paths cut at >>>>>>>>> those points, so you can then extract the ends that you need directly. >>>>>>>>> >>>>>>>>> Docs for path_cut: >>>>>>>>> https://github.com/revarbat/BOSL2/wiki/paths.scad#function-path_cut >>>>>>>>> >>>>>>>>> If you just want the code to work, here's the old function: >>>>>>>>> >>>>>>>>> function path_pos_from_start(path,length,closed=false,_d=0,_i=0) = >>>>>>>>> let (lp = len(path)) >>>>>>>>> _i >= lp - (closed?0:1)? undef : >>>>>>>>> let (l = norm(path[(_i+1)%lp]-path[_i])) >>>>>>>>> _d+l <= length? >>>>>>>>> path_pos_from_start(path,length,closed,_d+l,_i+1) : >>>>>>>>> [_i, (length-_d)/l]; >>>>>>>>> >>>>>>>>> On Tue, Oct 11, 2022 at 5:02 AM Mr Yura Volodin via Discuss < >>>>>>>>> discuss@lists.openscad.org> wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>>> discuss@lists.openscad.org> >>>>>>>>> Cc: >>>>>>>>> Bcc: >>>>>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> Direct replacement does not work. see attachment >>>>>>>>> >>>>>>>>> More info: >>>>>>>>> To reverse engineering saxophones for fdm 3dprinting I use two >>>>>>>>> curve approach. >>>>>>>>> One curve is path to "extrude" and second is - diameters along >>>>>>>>> this path. >>>>>>>>> After bulding tube I place toneholes, posts and etc, defined by >>>>>>>>> length from top of tube. >>>>>>>>> So I need function to return diameter at given length and angle to >>>>>>>>> rotate item I want to place >>>>>>>>> I draw curve manually in MOI3D then save as polyline dxf then >>>>>>>>> convert to openscad polyline with dxfwread.exe tool. >>>>>>>>> I almost solved all the above, but have a feel that there is more >>>>>>>>> elegant solution. >>>>>>>>> >>>>>>>>> Equal spacing along the curve is overkill on straight segments. >>>>>>>>> BSpline examples in this maillist seems to be useful but I didnot realize >>>>>>>>> how to implement. >>>>>>>>> I still didnot understand why length of the resulting tube depends >>>>>>>>> from quantization number and how to avoid its changing. >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>> >>>>>>>>> On Tuesday, October 11, 2022 at 12:55:06 AM GMT+3, Adrian Mariano < >>>>>>>>> avm4@cornell.edu> wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> I believe that path_pos_from_start was eliminated because it was >>>>>>>>> redundant with path_cut. Can path_cut do what you need? >>>>>>>>> >>>>>>>>> On Mon, Oct 10, 2022 at 11:56 AM Mr Yura Volodin via Discuss < >>>>>>>>> discuss@lists.openscad.org> wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>>> Cc: >>>>>>>>> Bcc: >>>>>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> I use this function in BOLS2 from 2020 for finding point to place >>>>>>>>> an item on curved tube. >>>>>>>>> It is absent in newer BOLS2. >>>>>>>>> What I need to use insteed ? >>>>>>>>> >>>>>>>>> SY, Yuri >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>>> To: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> Bcc: >>>>>>>>> Date: Mon, 10 Oct 2022 15:55:25 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> _______________________________________________ >>>>>>>>> OpenSCAD mailing list >>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> OpenSCAD mailing list >>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>>> discuss@lists.openscad.org> >>>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> Bcc: >>>>>>>>> Date: Tue, 11 Oct 2022 09:01:36 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> _______________________________________________ >>>>>>>>> OpenSCAD mailing list >>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> OpenSCAD mailing list >>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>>> discuss@lists.openscad.org> >>>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> Bcc: >>>>>>>>> Date: Wed, 12 Oct 2022 07:33:15 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> _______________________________________________ >>>>>>>>> OpenSCAD mailing list >>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> OpenSCAD mailing list >>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>> From: Mr Yura Volodin via Discuss <discuss@lists.openscad.org> >>>>>>>>> To: OpenSCAD general discussion Mailing-list < >>>>>>>>> discuss@lists.openscad.org> >>>>>>>>> Cc: Mr Yura Volodin <yur_vol@yahoo.com> >>>>>>>>> Bcc: >>>>>>>>> Date: Wed, 12 Oct 2022 12:03:12 +0000 (UTC) >>>>>>>>> Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? >>>>>>>>> _______________________________________________ >>>>>>>>> OpenSCAD mailing list >>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>>>> >>>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >