NH
nop head
Fri, Dec 1, 2017 3:20 PM
Does anybody here know how to model a flexible strip with rigidly held
ends? I.e. the maths to generate the curve. It's a bit like modelling a
catenary, but instead of being defined by gravity and tension, the main
force is the strip trying to be straight and not bent.
I crudely modelled the polypropylene strips I used in Mendel90 using arcs
but I need a more accurate model for my new machine.
Does anybody here know how to model a flexible strip with rigidly held
ends? I.e. the maths to generate the curve. It's a bit like modelling a
catenary, but instead of being defined by gravity and tension, the main
force is the strip trying to be straight and not bent.
I crudely modelled the polypropylene strips I used in Mendel90 using arcs
but I need a more accurate model for my new machine.
MK
Marius Kintel
Fri, Dec 1, 2017 3:45 PM
On Dec 1, 2017, at 10:20 AM, nop head nop.head@gmail.com wrote:
Does anybody here know how to model a flexible strip with rigidly held ends? I.e. the maths to generate the curve. It's a bit like modelling a catenary, but instead of being defined by gravity and tension, the main force is the strip trying to be straight and not bent.
This sounds very much like what Beziér curves were originally meant to be used for.
-Marius
> On Dec 1, 2017, at 10:20 AM, nop head <nop.head@gmail.com> wrote:
>
> Does anybody here know how to model a flexible strip with rigidly held ends? I.e. the maths to generate the curve. It's a bit like modelling a catenary, but instead of being defined by gravity and tension, the main force is the strip trying to be straight and not bent.
>
This sounds very much like what Beziér curves were originally meant to be used for.
-Marius
DM
doug moen
Fri, Dec 1, 2017 4:02 PM
On Dec 1, 2017, at 10:20 AM, nop head nop.head@gmail.com wrote:
Does anybody here know how to model a flexible strip with rigidly held
ends? I.e. the maths to generate the curve. It's a bit like modelling a
catenary, but instead of being defined by gravity and tension, the main
force is the strip trying to be straight and not bent.
Yes, a flexible strip was called a spline:
https://en.wikipedia.org/wiki/Flat_spline
On 1 December 2017 at 10:45, Marius Kintel <marius@kintel.net> wrote:
> > On Dec 1, 2017, at 10:20 AM, nop head <nop.head@gmail.com> wrote:
> >
> > Does anybody here know how to model a flexible strip with rigidly held
> ends? I.e. the maths to generate the curve. It's a bit like modelling a
> catenary, but instead of being defined by gravity and tension, the main
> force is the strip trying to be straight and not bent.
> >
> This sounds very much like what Beziér curves were originally meant to be
> used for.
>
> -Marius
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
CC
Chris Camacho
Fri, Dec 1, 2017 4:49 PM
you'd need something to constrain the total length of the sline thought
wouldn't you?
On 01/12/17 16:02, doug moen wrote:
rigidly held ends? I.e. the maths to generate the curve. It's a
bit like modelling a catenary, but instead of being defined by
gravity and tension, the main force is the strip trying to be
straight and not bent.
This sounds very much like what Beziér curves were originally
meant to be used for.
-Marius
_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
<http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org>
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
you'd need something to constrain the total length of the sline thought
wouldn't you?
On 01/12/17 16:02, doug moen wrote:
> Yes, a flexible strip was called a spline:
> https://en.wikipedia.org/wiki/Flat_spline
>
> On 1 December 2017 at 10:45, Marius Kintel <marius@kintel.net
> <mailto:marius@kintel.net>> wrote:
>
> > On Dec 1, 2017, at 10:20 AM, nop head <nop.head@gmail.com <mailto:nop.head@gmail.com>> wrote:
> >
> > Does anybody here know how to model a flexible strip with
> rigidly held ends? I.e. the maths to generate the curve. It's a
> bit like modelling a catenary, but instead of being defined by
> gravity and tension, the main force is the strip trying to be
> straight and not bent.
> >
> This sounds very much like what Beziér curves were originally
> meant to be used for.
>
> -Marius
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org>
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
NH
nop head
Fri, Dec 1, 2017 7:08 PM
Thanks for the pointers. I think what I need is a minimum energy spline
with a fixed length.
Playing with a Bezier spline using this tool
https://www.desmos.com/calculator/cahqdxeshd , I get something that looks
about right using four control points. The end points are obviously where
my ends are. The next points in seem to define tangents to the curve at is
ends. These can be on a line through the mounting plane. I.e. through the
planes the ends are clamped to. To get the length correct I can move those
two points equally away from the ends points until it is long enough. Since
there seems to be no easy way to calculate the length of a Bezier curve I
would need to compute it by recursive splitting the curve until it
converges. Then do a search moving the two points.
I have no idea if a Bezier spline is minimum energy or not.
On 1 December 2017 at 16:49, Chris Camacho chris@bedroomcoders.co.uk
wrote:
you'd need something to constrain the total length of the sline thought
wouldn't you?
On 01/12/17 16:02, doug moen wrote:
Yes, a flexible strip was called a spline: https://en.wikipedia.
org/wiki/Flat_spline
On 1 December 2017 at 10:45, Marius Kintel marius@kintel.net wrote:
On Dec 1, 2017, at 10:20 AM, nop head nop.head@gmail.com wrote:
Does anybody here know how to model a flexible strip with rigidly held
ends? I.e. the maths to generate the curve. It's a bit like modelling a
catenary, but instead of being defined by gravity and tension, the main
force is the strip trying to be straight and not bent.
Thanks for the pointers. I think what I need is a minimum energy spline
with a fixed length.
Playing with a Bezier spline using this tool
https://www.desmos.com/calculator/cahqdxeshd , I get something that looks
about right using four control points. The end points are obviously where
my ends are. The next points in seem to define tangents to the curve at is
ends. These can be on a line through the mounting plane. I.e. through the
planes the ends are clamped to. To get the length correct I can move those
two points equally away from the ends points until it is long enough. Since
there seems to be no easy way to calculate the length of a Bezier curve I
would need to compute it by recursive splitting the curve until it
converges. Then do a search moving the two points.
I have no idea if a Bezier spline is minimum energy or not.
On 1 December 2017 at 16:49, Chris Camacho <chris@bedroomcoders.co.uk>
wrote:
> you'd need something to constrain the total length of the sline thought
> wouldn't you?
>
> On 01/12/17 16:02, doug moen wrote:
>
> Yes, a flexible strip was called a spline: https://en.wikipedia.
> org/wiki/Flat_spline
>
> On 1 December 2017 at 10:45, Marius Kintel <marius@kintel.net> wrote:
>
>> > On Dec 1, 2017, at 10:20 AM, nop head <nop.head@gmail.com> wrote:
>> >
>> > Does anybody here know how to model a flexible strip with rigidly held
>> ends? I.e. the maths to generate the curve. It's a bit like modelling a
>> catenary, but instead of being defined by gravity and tension, the main
>> force is the strip trying to be straight and not bent.
>> >
>> This sounds very much like what Beziér curves were originally meant to be
>> used for.
>>
>> -Marius
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
>
>
> _______________________________________________
> OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
RP
Ronaldo Persiano
Fri, Dec 1, 2017 7:12 PM
Does anybody here know how to model a flexible strip with rigidly held
ends? I.e. the maths to generate the curve. It's a bit like modelling a
catenary, but instead of being defined by gravity and tension, the main
force is the strip trying to be straight and not bent.
I crudely modelled the polypropylene strips I used in Mendel90 using arcs
but I need a more accurate model for my new machine.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
May be a lot more complex then the flat splines. See:
https://en.wikipedia.org/wiki/Bending
2017-12-01 13:20 GMT-02:00 nop head <nop.head@gmail.com>:
> Does anybody here know how to model a flexible strip with rigidly held
> ends? I.e. the maths to generate the curve. It's a bit like modelling a
> catenary, but instead of being defined by gravity and tension, the main
> force is the strip trying to be straight and not bent.
>
> I crudely modelled the polypropylene strips I used in Mendel90 using arcs
> but I need a more accurate model for my new machine.
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
T
TLC123
Fri, Dec 1, 2017 8:57 PM
I had this nugget from another project.
module to draw a simple 4 point Bez curve.
function for piece-wise length estimation.
Simple enought to add a recursive function to fit control points for the
length of your pleasure.
Bezier_Length_Constrained.scad
http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad
function AdjustBezier(v,l, precision = 0.001)=
l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
[v[0],v[0] ,v[3] ,v[3]]:
let(
current_lenght=len3bz(v),
error=l/current_lenght,
new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
)
abs(1-error)>precision?AdjustBezier(new_v,l):v;
function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
precision, v)));
function bez2(t, v) = (len(v) > 2) ? bez2(t, [
for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
]): v[0] * (1 - t) + v[1] * (t);
module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1: len(v) - 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(v[i])) sphere(0.5);
translate(t(v[i - 1])) sphere(0.5);
}
}
}
module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [step:step: 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i, v) ))sphere(1);
translate(t(bez2(i-step, v))) sphere(1);
}
}
}
function t(v) = [v.x, v.y, v.z];
MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
Newlengh=75;
ShowControl(MyBezier) ;
ShowBezier(MyBezier) ;
echo(len3bz(MyBezier));
MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
color("red"){
ShowControl(MyNewBezier) ;
ShowBezier(MyNewBezier) ;
echo(len3bz(MyNewBezier));}
--
Sent from: http://forum.openscad.org/
I had this nugget from another project.
module to draw a simple 4 point Bez curve.
function for piece-wise length estimation.
Simple enought to add a recursive function to fit control points for the
length of your pleasure.
Bezier_Length_Constrained.scad
<http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad>
function AdjustBezier(v,l, precision = 0.001)=
l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
[v[0],v[0] ,v[3] ,v[3]]:
let(
current_lenght=len3bz(v),
error=l/current_lenght,
new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
)
abs(1-error)>precision?AdjustBezier(new_v,l):v;
function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
precision, v)));
function bez2(t, v) = (len(v) > 2) ? bez2(t, [
for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
]): v[0] * (1 - t) + v[1] * (t);
module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1: len(v) - 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(v[i])) sphere(0.5);
translate(t(v[i - 1])) sphere(0.5);
}
}
}
module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [step:step: 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i, v) ))sphere(1);
translate(t(bez2(i-step, v))) sphere(1);
}
}
}
function t(v) = [v.x, v.y, v.z];
MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
Newlengh=75;
ShowControl(MyBezier) ;
ShowBezier(MyBezier) ;
echo(len3bz(MyBezier));
MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
color("red"){
ShowControl(MyNewBezier) ;
ShowBezier(MyNewBezier) ;
echo(len3bz(MyNewBezier));}
--
Sent from: http://forum.openscad.org/
NH
nop head
Fri, Dec 1, 2017 9:21 PM
Thanks for that. Seems to do exactly what I proposed.
I found it did stop one point short when displaying the curve due to using
floating point in the for loop. I fixed it as follows
module ShowBezier(v,steps=20) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1 : steps]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i / steps, v) ))sphere(1);
translate(t(bez2((i - 1) / steps, v))) sphere(1);
}
}
}
On 1 December 2017 at 20:57, TLC123 torleif.ceder@gmail.com wrote:
I had this nugget from another project.
module to draw a simple 4 point Bez curve.
function for piece-wise length estimation.
Simple enought to add a recursive function to fit control points for the
length of your pleasure.
Bezier_Length_Constrained.scad
http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad
function AdjustBezier(v,l, precision = 0.001)=
l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
[v[0],v[0] ,v[3] ,v[3]]:
let(
current_lenght=len3bz(v),
error=l/current_lenght,
new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
)
abs(1-error)>precision?AdjustBezier(new_v,l):v;
function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
precision, v)));
function bez2(t, v) = (len(v) > 2) ? bez2(t, [
for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
]): v[0] * (1 - t) + v[1] * (t);
module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1: len(v) - 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(v[i])) sphere(0.5);
translate(t(v[i - 1])) sphere(0.5);
}
}
}
module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [step:step: 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i, v) ))sphere(1);
translate(t(bez2(i-step, v))) sphere(1);
}
}
}
function t(v) = [v.x, v.y, v.z];
MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
Newlengh=75;
ShowControl(MyBezier) ;
ShowBezier(MyBezier) ;
echo(len3bz(MyBezier));
MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
color("red"){
ShowControl(MyNewBezier) ;
ShowBezier(MyNewBezier) ;
echo(len3bz(MyNewBezier));}
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thanks for that. Seems to do exactly what I proposed.
I found it did stop one point short when displaying the curve due to using
floating point in the for loop. I fixed it as follows
module ShowBezier(v,steps=20) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1 : steps]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i / steps, v) ))sphere(1);
translate(t(bez2((i - 1) / steps, v))) sphere(1);
}
}
}
On 1 December 2017 at 20:57, TLC123 <torleif.ceder@gmail.com> wrote:
> I had this nugget from another project.
> module to draw a simple 4 point Bez curve.
> function for piece-wise length estimation.
>
> Simple enought to add a recursive function to fit control points for the
> length of your pleasure.
>
>
> Bezier_Length_Constrained.scad
> <http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad>
>
>
>
>
> function AdjustBezier(v,l, precision = 0.001)=
> l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
> [v[0],v[0] ,v[3] ,v[3]]:
> let(
> current_lenght=len3bz(v),
> error=l/current_lenght,
> new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
> )
> abs(1-error)>precision?AdjustBezier(new_v,l):v;
>
>
>
> function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
> len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
> precision, v)));
>
> function bez2(t, v) = (len(v) > 2) ? bez2(t, [
> for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
> ]): v[0] * (1 - t) + v[1] * (t);
>
> module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
>
> for (i = [1: len(v) - 1]) {
> // vg translate(t(v[i])) sphere(v[i][3]);
> hull() {
> translate(t(v[i])) sphere(0.5);
> translate(t(v[i - 1])) sphere(0.5);
> }
> }
> }
>
> module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
>
> for (i = [step:step: 1]) {
> // vg translate(t(v[i])) sphere(v[i][3]);
> hull() {
> translate(t(bez2(i, v) ))sphere(1);
> translate(t(bez2(i-step, v))) sphere(1);
> }
> }
> }
>
>
> function t(v) = [v.x, v.y, v.z];
>
> MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
> Newlengh=75;
>
> ShowControl(MyBezier) ;
> ShowBezier(MyBezier) ;
> echo(len3bz(MyBezier));
>
> MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
>
> color("red"){
> ShowControl(MyNewBezier) ;
> ShowBezier(MyNewBezier) ;
> echo(len3bz(MyNewBezier));}
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
NH
nop head
Sat, Dec 2, 2017 12:42 AM
Having worked my way through the code to understand it there are two things
that puzzle me.
Why is len3bz named with a 3? It looks like it would work on any Bezier
curve, not just cubic ones?
What is the t() function for. It seems like a NOP for 3d points and the
code works without it. Is it a leftover from some 4D code?
Thanks again, it does just what I needed. The curves it produces look
plausible. I am holiday at moment but when I get back I will attempt to
bend a strip over a 2D print of the curve and see if it matches.
On 1 December 2017 at 21:21, nop head nop.head@gmail.com wrote:
Thanks for that. Seems to do exactly what I proposed.
I found it did stop one point short when displaying the curve due to using
floating point in the for loop. I fixed it as follows
module ShowBezier(v,steps=20) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1 : steps]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i / steps, v) ))sphere(1);
translate(t(bez2((i - 1) / steps, v))) sphere(1);
}
}
}
On 1 December 2017 at 20:57, TLC123 torleif.ceder@gmail.com wrote:
I had this nugget from another project.
module to draw a simple 4 point Bez curve.
function for piece-wise length estimation.
Simple enought to add a recursive function to fit control points for the
length of your pleasure.
Bezier_Length_Constrained.scad
http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad
function AdjustBezier(v,l, precision = 0.001)=
l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
[v[0],v[0] ,v[3] ,v[3]]:
let(
current_lenght=len3bz(v),
error=l/current_lenght,
new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
)
abs(1-error)>precision?AdjustBezier(new_v,l):v;
function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
precision, v)));
function bez2(t, v) = (len(v) > 2) ? bez2(t, [
for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
]): v[0] * (1 - t) + v[1] * (t);
module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1: len(v) - 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(v[i])) sphere(0.5);
translate(t(v[i - 1])) sphere(0.5);
}
}
}
module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [step:step: 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i, v) ))sphere(1);
translate(t(bez2(i-step, v))) sphere(1);
}
}
}
function t(v) = [v.x, v.y, v.z];
MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
Newlengh=75;
ShowControl(MyBezier) ;
ShowBezier(MyBezier) ;
echo(len3bz(MyBezier));
MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
color("red"){
ShowControl(MyNewBezier) ;
ShowBezier(MyNewBezier) ;
echo(len3bz(MyNewBezier));}
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Having worked my way through the code to understand it there are two things
that puzzle me.
Why is len3bz named with a 3? It looks like it would work on any Bezier
curve, not just cubic ones?
What is the t() function for. It seems like a NOP for 3d points and the
code works without it. Is it a leftover from some 4D code?
Thanks again, it does just what I needed. The curves it produces look
plausible. I am holiday at moment but when I get back I will attempt to
bend a strip over a 2D print of the curve and see if it matches.
On 1 December 2017 at 21:21, nop head <nop.head@gmail.com> wrote:
> Thanks for that. Seems to do exactly what I proposed.
>
> I found it did stop one point short when displaying the curve due to using
> floating point in the for loop. I fixed it as follows
>
> module ShowBezier(v,steps=20) { // translate(t(v[0])) sphere(v[0][3]);
>
> for (i = [1 : steps]) {
> // vg translate(t(v[i])) sphere(v[i][3]);
> hull() {
> translate(t(bez2(i / steps, v) ))sphere(1);
> translate(t(bez2((i - 1) / steps, v))) sphere(1);
> }
> }
> }
>
>
> On 1 December 2017 at 20:57, TLC123 <torleif.ceder@gmail.com> wrote:
>
>> I had this nugget from another project.
>> module to draw a simple 4 point Bez curve.
>> function for piece-wise length estimation.
>>
>> Simple enought to add a recursive function to fit control points for the
>> length of your pleasure.
>>
>>
>> Bezier_Length_Constrained.scad
>> <http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad>
>>
>>
>>
>>
>> function AdjustBezier(v,l, precision = 0.001)=
>> l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
>> [v[0],v[0] ,v[3] ,v[3]]:
>> let(
>> current_lenght=len3bz(v),
>> error=l/current_lenght,
>> new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
>> )
>> abs(1-error)>precision?AdjustBezier(new_v,l):v;
>>
>>
>>
>> function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
>> len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
>> precision, v)));
>>
>> function bez2(t, v) = (len(v) > 2) ? bez2(t, [
>> for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
>> ]): v[0] * (1 - t) + v[1] * (t);
>>
>> module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
>>
>> for (i = [1: len(v) - 1]) {
>> // vg translate(t(v[i])) sphere(v[i][3]);
>> hull() {
>> translate(t(v[i])) sphere(0.5);
>> translate(t(v[i - 1])) sphere(0.5);
>> }
>> }
>> }
>>
>> module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
>>
>> for (i = [step:step: 1]) {
>> // vg translate(t(v[i])) sphere(v[i][3]);
>> hull() {
>> translate(t(bez2(i, v) ))sphere(1);
>> translate(t(bez2(i-step, v))) sphere(1);
>> }
>> }
>> }
>>
>>
>> function t(v) = [v.x, v.y, v.z];
>>
>> MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
>> Newlengh=75;
>>
>> ShowControl(MyBezier) ;
>> ShowBezier(MyBezier) ;
>> echo(len3bz(MyBezier));
>>
>> MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
>>
>> color("red"){
>> ShowControl(MyNewBezier) ;
>> ShowBezier(MyNewBezier) ;
>> echo(len3bz(MyNewBezier));}
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
>
RP
Ronaldo Persiano
Sat, Dec 2, 2017 2:28 AM
Without going deep in the code, there is something that seems
inappropriate. Given the two extreme points of cubic Bezier and the two
first derivative direction at those points, I would expect an infinite
number of solutions to the fixed length arc problem except in very
particular cases. It seems that Torleif's code chooses a particular
solution where the ratio of the norms of the two derivatives of the final
solution is the same as the corresponding ratio of the starting curve. So,
the solution found by the method depends not only on the two extreme points
and their tangents. But those are the only available data of the nophead's
initial problem.
2017-12-01 22:42 GMT-02:00 nop head nop.head@gmail.com:
Having worked my way through the code to understand it there are two
things that puzzle me.
Why is len3bz named with a 3? It looks like it would work on any Bezier
curve, not just cubic ones?
What is the t() function for. It seems like a NOP for 3d points and the
code works without it. Is it a leftover from some 4D code?
Thanks again, it does just what I needed. The curves it produces look
plausible. I am holiday at moment but when I get back I will attempt to
bend a strip over a 2D print of the curve and see if it matches.
On 1 December 2017 at 21:21, nop head nop.head@gmail.com wrote:
Thanks for that. Seems to do exactly what I proposed.
I found it did stop one point short when displaying the curve due to
using floating point in the for loop. I fixed it as follows
module ShowBezier(v,steps=20) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1 : steps]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i / steps, v) ))sphere(1);
translate(t(bez2((i - 1) / steps, v))) sphere(1);
}
}
}
On 1 December 2017 at 20:57, TLC123 torleif.ceder@gmail.com wrote:
I had this nugget from another project.
module to draw a simple 4 point Bez curve.
function for piece-wise length estimation.
Simple enought to add a recursive function to fit control points for the
length of your pleasure.
Bezier_Length_Constrained.scad
http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad
function AdjustBezier(v,l, precision = 0.001)=
l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
[v[0],v[0] ,v[3] ,v[3]]:
let(
current_lenght=len3bz(v),
error=l/current_lenght,
new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
)
abs(1-error)>precision?AdjustBezier(new_v,l):v;
function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
precision, v)));
function bez2(t, v) = (len(v) > 2) ? bez2(t, [
for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
]): v[0] * (1 - t) + v[1] * (t);
module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [1: len(v) - 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(v[i])) sphere(0.5);
translate(t(v[i - 1])) sphere(0.5);
}
}
}
module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
for (i = [step:step: 1]) {
// vg translate(t(v[i])) sphere(v[i][3]);
hull() {
translate(t(bez2(i, v) ))sphere(1);
translate(t(bez2(i-step, v))) sphere(1);
}
}
}
function t(v) = [v.x, v.y, v.z];
MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
Newlengh=75;
ShowControl(MyBezier) ;
ShowBezier(MyBezier) ;
echo(len3bz(MyBezier));
MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
color("red"){
ShowControl(MyNewBezier) ;
ShowBezier(MyNewBezier) ;
echo(len3bz(MyNewBezier));}
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Without going deep in the code, there is something that seems
inappropriate. Given the two extreme points of cubic Bezier and the two
first derivative direction at those points, I would expect an infinite
number of solutions to the fixed length arc problem except in very
particular cases. It seems that Torleif's code chooses a particular
solution where the ratio of the norms of the two derivatives of the final
solution is the same as the corresponding ratio of the starting curve. So,
the solution found by the method depends not only on the two extreme points
and their tangents. But those are the only available data of the nophead's
initial problem.
2017-12-01 22:42 GMT-02:00 nop head <nop.head@gmail.com>:
> Having worked my way through the code to understand it there are two
> things that puzzle me.
>
> Why is len3bz named with a 3? It looks like it would work on any Bezier
> curve, not just cubic ones?
>
> What is the t() function for. It seems like a NOP for 3d points and the
> code works without it. Is it a leftover from some 4D code?
>
> Thanks again, it does just what I needed. The curves it produces look
> plausible. I am holiday at moment but when I get back I will attempt to
> bend a strip over a 2D print of the curve and see if it matches.
>
> On 1 December 2017 at 21:21, nop head <nop.head@gmail.com> wrote:
>
>> Thanks for that. Seems to do exactly what I proposed.
>>
>> I found it did stop one point short when displaying the curve due to
>> using floating point in the for loop. I fixed it as follows
>>
>> module ShowBezier(v,steps=20) { // translate(t(v[0])) sphere(v[0][3]);
>>
>> for (i = [1 : steps]) {
>> // vg translate(t(v[i])) sphere(v[i][3]);
>> hull() {
>> translate(t(bez2(i / steps, v) ))sphere(1);
>> translate(t(bez2((i - 1) / steps, v))) sphere(1);
>> }
>> }
>> }
>>
>>
>> On 1 December 2017 at 20:57, TLC123 <torleif.ceder@gmail.com> wrote:
>>
>>> I had this nugget from another project.
>>> module to draw a simple 4 point Bez curve.
>>> function for piece-wise length estimation.
>>>
>>> Simple enought to add a recursive function to fit control points for the
>>> length of your pleasure.
>>>
>>>
>>> Bezier_Length_Constrained.scad
>>> <http://forum.openscad.org/file/t1678/Bezier_Length_Constrained.scad>
>>>
>>>
>>>
>>>
>>> function AdjustBezier(v,l, precision = 0.001)=
>>> l<norm(v[0]-v[3])?let(e=echo("Cant be that short, sorry"))
>>> [v[0],v[0] ,v[3] ,v[3]]:
>>> let(
>>> current_lenght=len3bz(v),
>>> error=l/current_lenght,
>>> new_v=[v[0],v[0]+(v[1]-v[0])*error,v[3]+(v[2]-v[3])*error,v[3]]
>>> )
>>> abs(1-error)>precision?AdjustBezier(new_v,l):v;
>>>
>>>
>>>
>>> function len3bz(v, precision = 0.001, t = 0, acc = 0) = t > 1 ? acc :
>>> len3bz(v, precision, t + precision, acc + norm(bez2(t, v) - bez2(t +
>>> precision, v)));
>>>
>>> function bez2(t, v) = (len(v) > 2) ? bez2(t, [
>>> for (i = [0: len(v) - 2]) v[i] * (1 - t) + v[i + 1] * (t)
>>> ]): v[0] * (1 - t) + v[1] * (t);
>>>
>>> module ShowControl(v) { // translate(t(v[0])) sphere(v[0][3]);
>>>
>>> for (i = [1: len(v) - 1]) {
>>> // vg translate(t(v[i])) sphere(v[i][3]);
>>> hull() {
>>> translate(t(v[i])) sphere(0.5);
>>> translate(t(v[i - 1])) sphere(0.5);
>>> }
>>> }
>>> }
>>>
>>> module ShowBezier(v,step=0.05) { // translate(t(v[0])) sphere(v[0][3]);
>>>
>>> for (i = [step:step: 1]) {
>>> // vg translate(t(v[i])) sphere(v[i][3]);
>>> hull() {
>>> translate(t(bez2(i, v) ))sphere(1);
>>> translate(t(bez2(i-step, v))) sphere(1);
>>> }
>>> }
>>> }
>>>
>>>
>>> function t(v) = [v.x, v.y, v.z];
>>>
>>> MyBezier=[[0,0,0],[0,0,10],[50,0,50],[50,10,50]];
>>> Newlengh=75;
>>>
>>> ShowControl(MyBezier) ;
>>> ShowBezier(MyBezier) ;
>>> echo(len3bz(MyBezier));
>>>
>>> MyNewBezier=AdjustBezier(MyBezier,Newlengh) ;
>>>
>>> color("red"){
>>> ShowControl(MyNewBezier) ;
>>> ShowBezier(MyNewBezier) ;
>>> echo(len3bz(MyNewBezier));}
>>>
>>>
>>>
>>> --
>>> Sent from: http://forum.openscad.org/
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> Discuss@lists.openscad.org
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>
>>
>>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>