discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Bezier stretch

WF
William F. Adams
Sun, Apr 19, 2026 12:50 PM

On Sunday, April 19, 2026 at 07:43:38 AM EDT, Caddiy via Discuss discuss@lists.openscad.org wrote:

The problem, though, is that I want to know how to get the length of a bezier here and now, 
so I can get on with the project.
7 % stretch is significant.

As I understand it, you want to know the beginning and endpoints of a specified distance along the central portion of a path which may or may not be the actual begin/endpoints.

So, you need to:

 - determine the actual length based on a specified path with a begin/end point
 - compare this length to the desired length
 - based on that difference either return the begin/end points (if the same) or, remove the difference from the beginning and ending portions of the path and return the begin/end points which are determined by applying the desired length to the path

As noted, this is a quite complex calculation --- a video which describes the complexity well is:

https://www.youtube.com/watch?v=jvPPXbo87ds

If you arrive at an understanding of the concepts and mathematics in that video, it should be possible to apply that calculus in OpenSCAD using the techniques from the afore-mentioned book:

https://www.goodreads.com/book/show/41392892-programming-with-openscad

It might be that there is some facility in Python which would allow calculating this more readily.

One approach might be to determine the half-way point of the path and from there, determine where the begin/end points are.

William

On Sunday, April 19, 2026 at 07:43:38 AM EDT, Caddiy via Discuss <discuss@lists.openscad.org> wrote: >The problem, though, is that I want to know how to get the length of a bezier here and now,  >so I can get on with the project. >7 % stretch is significant. As I understand it, you want to know the beginning and endpoints of a specified distance along the central portion of a path which may or may not be the actual begin/endpoints. So, you need to:  - determine the actual length based on a specified path with a begin/end point  - compare this length to the desired length  - based on that difference either return the begin/end points (if the same) or, remove the difference from the beginning and ending portions of the path and return the begin/end points which are determined by applying the desired length to the path As noted, this is a quite complex calculation --- a video which describes the complexity well is: https://www.youtube.com/watch?v=jvPPXbo87ds If you arrive at an understanding of the concepts and mathematics in that video, it should be possible to apply that calculus in OpenSCAD using the techniques from the afore-mentioned book: https://www.goodreads.com/book/show/41392892-programming-with-openscad It might be that there is some facility in Python which would allow calculating this more readily. One approach might be to determine the half-way point of the path and from there, determine where the begin/end points are. William
AM
Adrian Mariano
Sun, Apr 19, 2026 1:24 PM

I would say that the easiest way to solve this problem is to transform the
bezier into a path of actual points with bezpath_curve().  Now you can
compute its length with BOSL2 path_length().  Then you can use path_cut()
to find the section of the path that has the desired length.  It's
actually not particularly difficult and doesn't require knowledge of
advanced concepts.

On Sun, Apr 19, 2026 at 8:51 AM William F. Adams via Discuss <
discuss@lists.openscad.org> wrote:

On Sunday, April 19, 2026 at 07:43:38 AM EDT, Caddiy via Discuss <
discuss@lists.openscad.org> wrote:

The problem, though, is that I want to know how to get the length of a

bezier here and now,

so I can get on with the project.
7 % stretch is significant.

As I understand it, you want to know the beginning and endpoints of a
specified distance along the central portion of a path which may or may not
be the actual begin/endpoints.

So, you need to:

  • determine the actual length based on a specified path with a begin/end
    point
  • compare this length to the desired length
  • based on that difference either return the begin/end points (if the
    same) or, remove the difference from the beginning and ending portions of
    the path and return the begin/end points which are determined by applying
    the desired length to the path

As noted, this is a quite complex calculation --- a video which describes
the complexity well is:

https://www.youtube.com/watch?v=jvPPXbo87ds

If you arrive at an understanding of the concepts and mathematics in that
video, it should be possible to apply that calculus in OpenSCAD using the
techniques from the afore-mentioned book:

https://www.goodreads.com/book/show/41392892-programming-with-openscad

It might be that there is some facility in Python which would allow
calculating this more readily.

One approach might be to determine the half-way point of the path and from
there, determine where the begin/end points are.

William


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

I would say that the easiest way to solve this problem is to transform the bezier into a path of actual points with bezpath_curve(). Now you can compute its length with BOSL2 path_length(). Then you can use path_cut() to find the section of the path that has the desired length. It's actually not particularly difficult and doesn't require knowledge of advanced concepts. On Sun, Apr 19, 2026 at 8:51 AM William F. Adams via Discuss < discuss@lists.openscad.org> wrote: > On Sunday, April 19, 2026 at 07:43:38 AM EDT, Caddiy via Discuss < > discuss@lists.openscad.org> wrote: > > >The problem, though, is that I want to know how to get the length of a > bezier here and now, > >so I can get on with the project. > >7 % stretch is significant. > > As I understand it, you want to know the beginning and endpoints of a > specified distance along the central portion of a path which may or may not > be the actual begin/endpoints. > > So, you need to: > > - determine the actual length based on a specified path with a begin/end > point > - compare this length to the desired length > - based on that difference either return the begin/end points (if the > same) or, remove the difference from the beginning and ending portions of > the path and return the begin/end points which are determined by applying > the desired length to the path > > As noted, this is a quite complex calculation --- a video which describes > the complexity well is: > > https://www.youtube.com/watch?v=jvPPXbo87ds > > If you arrive at an understanding of the concepts and mathematics in that > video, it should be possible to apply that calculus in OpenSCAD using the > techniques from the afore-mentioned book: > > https://www.goodreads.com/book/show/41392892-programming-with-openscad > > It might be that there is some facility in Python which would allow > calculating this more readily. > > One approach might be to determine the half-way point of the path and from > there, determine where the begin/end points are. > > William > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Sun, Apr 19, 2026 5:23 PM

On 4/19/2026 6:24 AM, Adrian Mariano via Discuss wrote:

I would say that the easiest way to solve this problem is to transform
the bezier into a path of actual points with bezpath_curve().  Now you
can compute its length with BOSL2 path_length().  Then you can use
path_cut() to find the section of the path that has the desired
length.   It's actually not particularly difficult and doesn't require
knowledge of advanced concepts.  

But... does that do what the OP wants?

The problem seems intuitively simple:

  • Start with a straight line segment.
  • Bend it into a Bézier S curve:
    o Maintain the Bézier property that the ends merge smoothly into
    the original line.
    o Pull the endpoints (along the original line) in so that the
    length stays the same as the original segment.

As I understood it, the OP didn't want some piece of a Bézier S curve
where the ends are pointing in some random direction; the ends need to
point along the original line.

Thinking of it in physical reality...

Have a long piece of (bendable) PVC pipe, connected at both ends to
(unbendable) iron pipe.
Put the iron pipes in a track that allows them to slide lengthwise, but
not turn.
Grab the PVC pipe in the middle, and twist it, bending the PVC pipe into
an S curve.

The length of the PVC pipe stays the same, but the iron pipes get pulled
toward the center.

But the fact that it's intuitively simple doesn't necessarily mean that
it's mathematically simple...

On 4/19/2026 6:24 AM, Adrian Mariano via Discuss wrote: > I would say that the easiest way to solve this problem is to transform > the bezier into a path of actual points with bezpath_curve().  Now you > can compute its length with BOSL2 path_length().  Then you can use > path_cut() to find the section of the path that has the desired > length.   It's actually not particularly difficult and doesn't require > knowledge of advanced concepts.   But... does that do what the OP wants? The problem seems intuitively simple: * Start with a straight line segment. * Bend it into a Bézier S curve: o Maintain the Bézier property that the ends merge smoothly into the original line. o Pull the endpoints (along the original line) in so that the length stays the same as the original segment. As I understood it, the OP didn't want some piece of a Bézier S curve where the ends are pointing in some random direction; the ends need to point along the original line. Thinking of it in physical reality... Have a long piece of (bendable) PVC pipe, connected at both ends to (unbendable) iron pipe. Put the iron pipes in a track that allows them to slide lengthwise, but not turn. Grab the PVC pipe in the middle, and twist it, bending the PVC pipe into an S curve. The length of the PVC pipe stays the same, but the iron pipes get pulled toward the center. But the fact that it's intuitively simple doesn't necessarily mean that it's mathematically simple...
M
mikeonenine@web.de
Sun, Apr 19, 2026 11:20 PM

Jordan Brown wrote:

Thinking of it in physical reality...

Have a long piece of (bendable) PVC pipe, connected at both ends to
(unbendable) iron pipe.
Put the iron pipes in a track that allows them to slide lengthwise, but
not turn.
Grab the PVC pipe in the middle, and twist it, bending the PVC pipe into
an S curve.

The length of the PVC pipe stays the same, but the iron pipes get pulled
toward the center.

That comes closest.

One end of the bezier is rigidly fixed to the triangle that rocks from side to side (x-direction), the other to a piston or plunger (not shown) that can slide back and forth in a cylinder.

But the fact that it's intuitively simple doesn't necessarily mean that
it's mathematically simple...

The outer end of the bezier has a sinusoidal correction, not mathematically perfect, but close as dammit.

Next I need to consider the rocking motion of the triangle in the z-direction, then combine the two.

Jordan Brown wrote: > Thinking of it in physical reality... > > Have a long piece of (bendable) PVC pipe, connected at both ends to > (unbendable) iron pipe. > Put the iron pipes in a track that allows them to slide lengthwise, but > not turn. > Grab the PVC pipe in the middle, and twist it, bending the PVC pipe into > an S curve. > > The length of the PVC pipe stays the same, but the iron pipes get pulled > toward the center. That comes closest. One end of the bezier is rigidly fixed to the triangle that rocks from side to side (x-direction), the other to a piston or plunger (not shown) that can slide back and forth in a cylinder. > But the fact that it's intuitively simple doesn't necessarily mean that > it's mathematically simple... The outer end of the bezier has a sinusoidal correction, not mathematically perfect, but close as dammit. Next I need to consider the rocking motion of the triangle in the z-direction, then combine the two.
SP
Sanjeev Prabhakar
Mon, Apr 20, 2026 2:50 AM

Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png]

On Mon, 20 Apr 2026 at 04:51, Caddiy via Discuss discuss@lists.openscad.org
wrote:

Jordan Brown wrote:

Thinking of it in physical reality...

Have a long piece of (bendable) PVC pipe, connected at both ends to
(unbendable) iron pipe. Put the iron pipes in a track that allows them to
slide lengthwise, but not turn. Grab the PVC pipe in the middle, and twist
it, bending the PVC pipe into an S curve.

The length of the PVC pipe stays the same, but the iron pipes get pulled
toward the center.

That comes closest.

One end of the bezier is rigidly fixed to the triangle that rocks from
side to side (x-direction), the other to a piston or plunger (not shown)
that can slide back and forth in a cylinder.

But the fact that it's intuitively simple doesn't necessarily mean that
it's mathematically simple...

The outer end of the bezier has a sinusoidal correction, not
mathematically perfect, but close as dammit.

Next I need to consider the rocking motion of the triangle in the
z-direction, then combine the two.


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

Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png] On Mon, 20 Apr 2026 at 04:51, Caddiy via Discuss <discuss@lists.openscad.org> wrote: > Jordan Brown wrote: > > Thinking of it in physical reality... > > Have a long piece of (bendable) PVC pipe, connected at both ends to > (unbendable) iron pipe. Put the iron pipes in a track that allows them to > slide lengthwise, but not turn. Grab the PVC pipe in the middle, and twist > it, bending the PVC pipe into an S curve. > > The length of the PVC pipe stays the same, but the iron pipes get pulled > toward the center. > > That comes closest. > > One end of the bezier is rigidly fixed to the triangle that rocks from > side to side (x-direction), the other to a piston or plunger (not shown) > that can slide back and forth in a cylinder. > > But the fact that it's intuitively simple doesn't necessarily mean that > it's mathematically simple... > > The outer end of the bezier has a sinusoidal correction, not > mathematically perfect, but close as dammit. > > Next I need to consider the rocking motion of the triangle in the > z-direction, then combine the two. > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
M
mikeonenine@web.de
Mon, Apr 20, 2026 5:07 AM

Sanjeev Prabhakar wrote:

Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png]

How do you get all those numbers? Could be useful for complex 3D surfaces.

Nice constant-length bezier, but the code is beyond me!

It would be nice to be able to get the difference between the actual length of the bezier, and what it should be, and feed that as a correction back into the bezier. But I think it would make the computer go round and round in ever-decreasing circles.

However, it could be done with two identical beziers, a “real” one and a “dummy”.  The dummy calculates the correction and that is fed not back into the dummy but into the real bezier, using a function or whatever. I’m just wondering whether both beziers can be obtained from a single module, or whether the dummy would have to be cut and pasted from the real one. Is that mathematically permissible?

I’ll try it out tomorrow.

Sanjeev Prabhakar wrote: > Maybe this comes closer\[image: Screenshot 2026-04-20 at 8.18.59 AM.png\] How do you get all those numbers? Could be useful for complex 3D surfaces. Nice constant-length bezier, but the code is beyond me! It would be nice to be able to get the difference between the actual length of the bezier, and what it should be, and feed that as a correction back into the bezier. But I think it would make the computer go round and round in ever-decreasing circles. However, it could be done with two identical beziers, a “real” one and a “dummy”. The dummy calculates the correction and that is fed not back into the dummy but into the real bezier, using a function or whatever. I’m just wondering whether both beziers can be obtained from a single module, or whether the dummy would have to be cut and pasted from the real one. Is that mathematically permissible? I’ll try it out tomorrow.
JB
Jon Bondy
Mon, Apr 20, 2026 11:37 AM

The "code" is unreadable.  It is not a useful example of how to use
OpenSCAD.

On 4/19/2026 10:50 PM, Sanjeev Prabhakar via Discuss wrote:

Maybe this comes closerScreenshot 2026-04-20 at 8.18.59 AM.png

On Mon, 20 Apr 2026 at 04:51, Caddiy via Discuss
discuss@lists.openscad.org wrote:

 Jordan Brown wrote:

     Thinking of it in physical reality...

     Have a long piece of (bendable) PVC pipe, connected at both
     ends to (unbendable) iron pipe. Put the iron pipes in a track
     that allows them to slide lengthwise, but not turn. Grab the
     PVC pipe in the middle, and twist it, bending the PVC pipe
     into an S curve.

     The length of the PVC pipe stays the same, but the iron pipes
     get pulled toward the center.

 That comes closest.

 One end of the bezier is rigidly fixed to the triangle that rocks
 from side to side (x-direction), the other to a piston or plunger
 (not shown) that can slide back and forth in a cylinder.

     But the fact that it's intuitively simple doesn't necessarily
     mean that it's mathematically simple...

 The outer end of the bezier has a sinusoidal correction, not
 mathematically perfect, but close as dammit.

 Next I need to consider the rocking motion of the triangle in the
 z-direction, then combine the two.


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

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

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

The "code" is unreadable.  It is not a useful example of how to use OpenSCAD. On 4/19/2026 10:50 PM, Sanjeev Prabhakar via Discuss wrote: > Maybe this comes closerScreenshot 2026-04-20 at 8.18.59 AM.png > > On Mon, 20 Apr 2026 at 04:51, Caddiy via Discuss > <discuss@lists.openscad.org> wrote: > > Jordan Brown wrote: > > Thinking of it in physical reality... > > Have a long piece of (bendable) PVC pipe, connected at both > ends to (unbendable) iron pipe. Put the iron pipes in a track > that allows them to slide lengthwise, but not turn. Grab the > PVC pipe in the middle, and twist it, bending the PVC pipe > into an S curve. > > The length of the PVC pipe stays the same, but the iron pipes > get pulled toward the center. > > That comes closest. > > One end of the bezier is rigidly fixed to the triangle that rocks > from side to side (x-direction), the other to a piston or plunger > (not shown) that can slide back and forth in a cylinder. > > But the fact that it's intuitively simple doesn't necessarily > mean that it's mathematically simple... > > The outer end of the bezier has a sinusoidal correction, not > mathematically perfect, but close as dammit. > > Next I need to consider the rocking motion of the triangle in the > z-direction, then combine the two. > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
SP
Sanjeev Prabhakar
Mon, Apr 20, 2026 3:03 PM

Code can be written in more comprehensive manner later.

First point is whether this is the correct understanding of the problem.

If this is correct, exact bezier length can be modeled as per me.

Now does it stop here, only in 1 plane e.g. this is in x-z plane or the
entire thing has to be rotated around x-axis as well.

More interesting would be to understand the purpose,  it feels like an NVH
(Noise Vibration and Harshness) simulation of a beam.

Thanks

On Mon, 20 Apr, 2026, 10:37 am Caddiy via Discuss, <
discuss@lists.openscad.org> wrote:

Sanjeev Prabhakar wrote:

Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png]

How do you get all those numbers? Could be useful for complex 3D surfaces.

Nice constant-length bezier, but the code is beyond me!

It would be nice to be able to get the difference between the actual
length of the bezier, and what it should be, and feed that as a correction
back into the bezier. But I think it would make the computer go round and
round in ever-decreasing circles.

However, it could be done with two identical beziers, a “real” one and a
“dummy”. The dummy calculates the correction and that is fed not back into
the dummy but into the real bezier, using a function or whatever. I’m just
wondering whether both beziers can be obtained from a single module, or
whether the dummy would have to be cut and pasted from the real one. Is
that mathematically permissible?

I’ll try it out tomorrow.


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

Code can be written in more comprehensive manner later. First point is whether this is the correct understanding of the problem. If this is correct, exact bezier length can be modeled as per me. Now does it stop here, only in 1 plane e.g. this is in x-z plane or the entire thing has to be rotated around x-axis as well. More interesting would be to understand the purpose, it feels like an NVH (Noise Vibration and Harshness) simulation of a beam. Thanks On Mon, 20 Apr, 2026, 10:37 am Caddiy via Discuss, < discuss@lists.openscad.org> wrote: > Sanjeev Prabhakar wrote: > > Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png] > > How do you get all those numbers? Could be useful for complex 3D surfaces. > > Nice constant-length bezier, but the code is beyond me! > > It would be nice to be able to get the difference between the actual > length of the bezier, and what it should be, and feed that as a correction > back into the bezier. But I think it would make the computer go round and > round in ever-decreasing circles. > > However, it could be done with two identical beziers, a “real” one and a > “dummy”. The dummy calculates the correction and that is fed not back into > the dummy but into the real bezier, using a function or whatever. I’m just > wondering whether both beziers can be obtained from a single module, or > whether the dummy would have to be cut and pasted from the real one. Is > that mathematically permissible? > > I’ll try it out tomorrow. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
M
mikeonenine@web.de
Mon, Apr 20, 2026 9:41 PM

Sanjeev Prabhakar wrote:

First point is whether this is the correct understanding of the problem.

If this is correct, exact bezier length can be modeled as per me.

You have the right idea, and I can’t criticise the code as such, but it is much longer than I think it needs to be and far advanced beyond my level of coding. I’m not happy with blindly taking over things I don’t understand.

Now does it stop here, only in 1 plane e.g. this is in x-z plane or the
entire thing has to be rotated around x-axis as well.

More interesting would be to understand the purpose,  it feels like an NVH
(Noise Vibration and Harshness) simulation of a beam.

NVH is very close. I want to simulate the bending of a piston rod caused by the (unintended) precession of the triangle in the animation. The triangle represents one half of a type of crank. The precession can of course be broken down into rocking motions along two axes. I have done that, and beziers seem to provide an accurate representation of the bending. Try it with a hacksaw blade! The problem here and now is that, while the length of a hacksaw blade (or piston rod etc.) doesn’t change when you bend it, beziers do - they get longer. In OpenSCAD this means that parts can overlap or gaps can open and close. This should not be, and here I am looking for a correction for it.

Having said that, any gaps or overlaps in the present case would be inside the piston and would be practically invisible, as long as the rod doesn’t poke through the piston crown.

Thanks

On Mon, 20 Apr, 2026, 10:37 am Caddiy via Discuss, <
discuss@lists.openscad.org> wrote:

Sanjeev Prabhakar wrote:

Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png]

How do you get all those numbers? Could be useful for complex 3D surfaces.

Nice constant-length bezier, but the code is beyond me!

It would be nice to be able to get the difference between the actual
length of the bezier, and what it should be, and feed that as a correction
back into the bezier. But I think it would make the computer go round and
round in ever-decreasing circles.

However, it could be done with two identical beziers, a “real” one and a
“dummy”. The dummy calculates the correction and that is fed not back into
the dummy but into the real bezier, using a function or whatever. I’m just
wondering whether both beziers can be obtained from a single module, or
whether the dummy would have to be cut and pasted from the real one. Is
that mathematically permissible?

I’ll try it out tomorrow.


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

Sanjeev Prabhakar wrote: > First point is whether this is the correct understanding of the problem. > > If this is correct, exact bezier length can be modeled as per me. You have the right idea, and I can’t criticise the code as such, but it is much longer than I think it needs to be and far advanced beyond my level of coding. I’m not happy with blindly taking over things I don’t understand. > Now does it stop here, only in 1 plane e.g. this is in x-z plane or the > entire thing has to be rotated around x-axis as well. > > More interesting would be to understand the purpose, it feels like an NVH > (Noise Vibration and Harshness) simulation of a beam. NVH is very close. I want to simulate the bending of a piston rod caused by the (unintended) precession of the triangle in the animation. The triangle represents one half of a type of crank. The precession can of course be broken down into rocking motions along two axes. I have done that, and beziers seem to provide an accurate representation of the bending. Try it with a hacksaw blade! The problem here and now is that, while the length of a hacksaw blade (or piston rod etc.) doesn’t change when you bend it, beziers do - they get longer. In OpenSCAD this means that parts can overlap or gaps can open and close. This should not be, and here I am looking for a correction for it. Having said that, any gaps or overlaps in the present case would be inside the piston and would be practically invisible, as long as the rod doesn’t poke through the piston crown. > Thanks > > On Mon, 20 Apr, 2026, 10:37 am Caddiy via Discuss, < > discuss@lists.openscad.org> wrote: > > > Sanjeev Prabhakar wrote: > > > > Maybe this comes closer\[image: Screenshot 2026-04-20 at 8.18.59 AM.png\] > > > > How do you get all those numbers? Could be useful for complex 3D surfaces. > > > > Nice constant-length bezier, but the code is beyond me! > > > > It would be nice to be able to get the difference between the actual > > length of the bezier, and what it should be, and feed that as a correction > > back into the bezier. But I think it would make the computer go round and > > round in ever-decreasing circles. > > > > However, it could be done with two identical beziers, a “real” one and a > > “dummy”. The dummy calculates the correction and that is fed not back into > > the dummy but into the real bezier, using a function or whatever. I’m just > > wondering whether both beziers can be obtained from a single module, or > > whether the dummy would have to be cut and pasted from the real one. Is > > that mathematically permissible? > > > > I’ll try it out tomorrow. > > > > --- > > > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org
AM
Adrian Mariano
Mon, Apr 20, 2026 11:28 PM

"It would be nice to be able to get the difference between the actual
length of the bezier, and what it should be, and feed that as a correction
back into the bezier. But I think it would make the computer go round and
round in ever-decreasing circles."

This is basically how the vast majority of numerical computations work.
You just have to define a stopping criterion for when the answer is good
enough so that the computation stops rather than going for ever.  Very few
interesting computations can be done precisely in a finite number of
steps.  You can't compute sqrt(x) or cos(theta) in a finite number of
steps.

Also, cutting and pasting answers from your code back into the code is
never the answer.  Imagine if you had to do that 1000 times to get to the
solution you wanted---just not practical.

On Mon, Apr 20, 2026 at 5:42 PM Caddiy via Discuss <
discuss@lists.openscad.org> wrote:

Sanjeev Prabhakar wrote:

First point is whether this is the correct understanding of the problem.

If this is correct, exact bezier length can be modeled as per me.

You have the right idea, and I can’t criticise the code as such, but it is
much longer than I think it needs to be and far advanced beyond my level of
coding. I’m not happy with blindly taking over things I don’t understand.

Now does it stop here, only in 1 plane e.g. this is in x-z plane or the
entire thing has to be rotated around x-axis as well.

More interesting would be to understand the purpose, it feels like an NVH
(Noise Vibration and Harshness) simulation of a beam.

NVH is very close. I want to simulate the bending of a piston rod caused
by the (unintended) precession of the triangle in the animation. The
triangle represents one half of a type of crank. The precession can of
course be broken down into rocking motions along two axes. I have done
that, and beziers seem to provide an accurate representation of the
bending. Try it with a hacksaw blade! The problem here and now is that,
while the length of a hacksaw blade (or piston rod etc.) doesn’t change
when you bend it, beziers do - they get longer. In OpenSCAD this means that
parts can overlap or gaps can open and close. This should not be, and here
I am looking for a correction for it.

Having said that, any gaps or overlaps in the present case would be inside
the piston and would be practically invisible, as long as the rod doesn’t
poke through the piston crown.

Thanks

On Mon, 20 Apr, 2026, 10:37 am Caddiy via Discuss, <
discuss@lists.openscad.org> wrote:

Sanjeev Prabhakar wrote:

Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png]

How do you get all those numbers? Could be useful for complex 3D surfaces.

Nice constant-length bezier, but the code is beyond me!

It would be nice to be able to get the difference between the actual
length of the bezier, and what it should be, and feed that as a correction
back into the bezier. But I think it would make the computer go round and
round in ever-decreasing circles.

However, it could be done with two identical beziers, a “real” one and a
“dummy”. The dummy calculates the correction and that is fed not back into
the dummy but into the real bezier, using a function or whatever. I’m just
wondering whether both beziers can be obtained from a single module, or
whether the dummy would have to be cut and pasted from the real one. Is
that mathematically permissible?

I’ll try it out tomorrow.

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

"It would be nice to be able to get the difference between the actual length of the bezier, and what it should be, and feed that as a correction back into the bezier. But I think it would make the computer go round and round in ever-decreasing circles." This is basically how the vast majority of numerical computations work. You just have to define a stopping criterion for when the answer is good enough so that the computation stops rather than going for ever. Very few interesting computations can be done precisely in a finite number of steps. You can't compute sqrt(x) or cos(theta) in a finite number of steps. Also, cutting and pasting answers from your code back into the code is never the answer. Imagine if you had to do that 1000 times to get to the solution you wanted---just not practical. On Mon, Apr 20, 2026 at 5:42 PM Caddiy via Discuss < discuss@lists.openscad.org> wrote: > Sanjeev Prabhakar wrote: > > First point is whether this is the correct understanding of the problem. > > If this is correct, exact bezier length can be modeled as per me. > > You have the right idea, and I can’t criticise the code as such, but it is > much longer than I think it needs to be and far advanced beyond my level of > coding. I’m not happy with blindly taking over things I don’t understand. > > Now does it stop here, only in 1 plane e.g. this is in x-z plane or the > entire thing has to be rotated around x-axis as well. > > More interesting would be to understand the purpose, it feels like an NVH > (Noise Vibration and Harshness) simulation of a beam. > > NVH is very close. I want to simulate the bending of a piston rod caused > by the (unintended) precession of the triangle in the animation. The > triangle represents one half of a type of crank. The precession can of > course be broken down into rocking motions along two axes. I have done > that, and beziers seem to provide an accurate representation of the > bending. Try it with a hacksaw blade! The problem here and now is that, > while the length of a hacksaw blade (or piston rod etc.) doesn’t change > when you bend it, beziers do - they get longer. In OpenSCAD this means that > parts can overlap or gaps can open and close. This should not be, and here > I am looking for a correction for it. > > Having said that, any gaps or overlaps in the present case would be inside > the piston and would be practically invisible, as long as the rod doesn’t > poke through the piston crown. > > > Thanks > > On Mon, 20 Apr, 2026, 10:37 am Caddiy via Discuss, < > discuss@lists.openscad.org> wrote: > > Sanjeev Prabhakar wrote: > > Maybe this comes closer[image: Screenshot 2026-04-20 at 8.18.59 AM.png] > > How do you get all those numbers? Could be useful for complex 3D surfaces. > > Nice constant-length bezier, but the code is beyond me! > > It would be nice to be able to get the difference between the actual > length of the bezier, and what it should be, and feed that as a correction > back into the bezier. But I think it would make the computer go round and > round in ever-decreasing circles. > > However, it could be done with two identical beziers, a “real” one and a > “dummy”. The dummy calculates the correction and that is fed not back into > the dummy but into the real bezier, using a function or whatever. I’m just > wondering whether both beziers can be obtained from a single module, or > whether the dummy would have to be cut and pasted from the real one. Is > that mathematically permissible? > > I’ll try it out tomorrow. > ------------------------------ > > 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