discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Where is "path_pos_from_start" in BOLS2 ?

AM
Adrian Mariano
Thu, Oct 13, 2022 10:40 AM

Yes, if you draw pb with stroke() you see two lines "like you expect" but
it doesn't mean that it is correct or meaningful to interpolate this data
in 2d like resample_path() does.  The length of the path is a meaningless
value for this data, but the path resampling routines treat the path based
on its length.

Your new example with the new pb that you use actually makes the problem
much larger.  You were getting away with it before because pb was very
close to just being a straight line, so the error was small.  But with your
new example, the error is now 10 - 15 units.  The cylinder you use to cut
away at one end appears in the wrong place and cuts into the curve.  This
makes it reasonably clear that the code is not following your intent and
that the errors may be a real problem for you under some parameters.

I would argue that even if the error is small you should code correctly,
not write code that is wrong (and actually more complex) and be happy that
the error is just small.  Better to understand what you are doing and do it
right!  Or intentionally make an approximation that introduces a known
small error.  In your case, the error is only small if the radius has the
right shape, and no longer in your second example.  Note also that my
neck2.scad version is faster than your code and produces a nicer tube since
the ends are correct in preview.  If you don't want to use sweep() the way
that one does you can still use the old hull() approach, but with lookup()
to compute the diameters.

On Thu, Oct 13, 2022 at 6:09 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: Thu, 13 Oct 2022 10:08:10 +0000 (UTC)
Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ?
Im a bit confused  I think that lookup table are the same as 2d curve with
linear interpolation

*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?

In my* pb* coordinates  are swapped.  pb=[[
diam0,length0],[diam1,length1], and so on].
I measured diams with a caliper on my brass sax neck. and measured
aproximately length from wider end of neck.

As for neck1200.scad  I set test as you suggest::
pb = [ [50+26.0127,264.979+8],[18,170],[12.3567,0]] ;
When I draw this  with 'stroke' I see two linear line  (see blue line). as
I expect.

  • 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.*

How it can be? beyond the boundaries?

*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.  *

As I measure manually there is an error ( estimatly 0.5-1.5mm or more on
bented regions) . Second error is of conicity  but the angle is small and I
ignore it..
I think difference between exact and approximate  L is within very small
region.

---------- 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: Thu, 13 Oct 2022 10:08:10 +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

Yes, if you draw pb with stroke() you see two lines "like you expect" but it doesn't mean that it is correct or meaningful to interpolate this data in 2d like resample_path() does. The length of the path is a meaningless value for this data, but the path resampling routines treat the path based on its length. Your new example with the new pb that you use actually makes the problem much larger. You were getting away with it before because pb was very close to just being a straight line, so the error was small. But with your new example, the error is now 10 - 15 units. The cylinder you use to cut away at one end appears in the wrong place and cuts into the curve. This makes it reasonably clear that the code is not following your intent and that the errors may be a real problem for you under some parameters. I would argue that even if the error is small you should code correctly, not write code that is wrong (and actually more complex) and be happy that the error is just small. Better to understand what you are doing and do it right! Or intentionally make an approximation that introduces a known small error. In your case, the error is only small if the radius has the right shape, and no longer in your second example. Note also that my neck2.scad version is faster than your code and produces a nicer tube since the ends are correct in preview. If you don't want to use sweep() the way that one does you can still use the old hull() approach, but with lookup() to compute the diameters. On Thu, Oct 13, 2022 at 6:09 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: Thu, 13 Oct 2022 10:08:10 +0000 (UTC) > Subject: [OpenSCAD] Re: Where is "path_pos_from_start" in BOLS2 ? > Im a bit confused I think that lookup table are the same as 2d curve with > linear interpolation > > > > *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?* > > In my* pb* coordinates are swapped. pb=[[ > diam0,length0],[diam1,length1], and so on]. > I measured diams with a caliper on my brass sax neck. and measured > aproximately length from wider end of neck. > > As for neck1200.scad I set test as you suggest:: > pb = [ [50+26.0127,264.979+8],[18,170],[12.3567,0]] ; > When I draw this with 'stroke' I see two linear line (see blue line). as > I expect. > > > * 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.* > > How it can be? beyond the boundaries? > > *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. * > > As I measure manually there is an error ( estimatly 0.5-1.5mm or more on > bented regions) . Second error is of conicity but the angle is small and I > ignore it.. > I think difference between exact and approximate L is within very small > region. > > > > > > ---------- 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: Thu, 13 Oct 2022 10:08:10 +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 >
MY
Mr Yura Volodin
Thu, Oct 13, 2022 6:54 PM

I will go on with your sweep code. but 
There is a problem.
Your code generates tube with walls. Insteed of subracting all internals from externals.
This makes placing items complicated as I need to empty tube after all once more.
Howto do it correctly? See pic
On Thursday, October 13, 2022 at 01:40:53 PM GMT+3, Adrian Mariano avm4@cornell.edu wrote:

Yes, if you draw pb with stroke() you see two lines "like you expect" but it doesn't mean that it is correct or meaningful to interpolate this data in 2d like resample_path() does.  The length of the path is a meaningless value for this data, but the path resampling routines treat the path based on its length. 

Your new example with the new pb that you use actually makes the problem much larger.  You were getting away with it before because pb was very close to just being a straight line, so the error was small.  But with your new example, the error is now 10 - 15 units.  The cylinder you use to cut away at one end appears in the wrong place and cuts into the curve.  This makes it reasonably clear that the code is not following your intent and that the errors may be a real problem for you under some parameters. 

I would argue that even if the error is small you should code correctly, not write code that is wrong (and actually more complex) and be happy that the error is just small.  Better to understand what you are doing and do it right!   Or intentionally make an approximation that introduces a known small error.  In your case, the error is only small if the radius has the right shape, and no longer in your second example.  Note also that my neck2.scad version is faster than your code and produces a nicer tube since the ends are correct in preview.   If you don't want to use sweep() the way that one does you can still use the old hull() approach, but with lookup() to compute the diameters. 

I will go on with your sweep code. but  There is a problem. Your code generates tube with walls. Insteed of subracting all internals from externals. This makes placing items complicated as I need to empty tube after all once more. Howto do it correctly? See pic On Thursday, October 13, 2022 at 01:40:53 PM GMT+3, Adrian Mariano <avm4@cornell.edu> wrote: Yes, if you draw pb with stroke() you see two lines "like you expect" but it doesn't mean that it is correct or meaningful to interpolate this data in 2d like resample_path() does.  The length of the path is a meaningless value for this data, but the path resampling routines treat the path based on its length.  Your new example with the new pb that you use actually makes the problem much larger.  You were getting away with it before because pb was very close to just being a straight line, so the error was small.  But with your new example, the error is now 10 - 15 units.  The cylinder you use to cut away at one end appears in the wrong place and cuts into the curve.  This makes it reasonably clear that the code is not following your intent and that the errors may be a real problem for you under some parameters.  I would argue that even if the error is small you should code correctly, not write code that is wrong (and actually more complex) and be happy that the error is just small.  Better to understand what you are doing and do it right!   Or intentionally make an approximation that introduces a known small error.  In your case, the error is only small if the radius has the right shape, and no longer in your second example.  Note also that my neck2.scad version is faster than your code and produces a nicer tube since the ends are correct in preview.   If you don't want to use sweep() the way that one does you can still use the old hull() approach, but with lookup() to compute the diameters.