discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Bezier disappears!

M
mikeonenine@web.de
Sun, Oct 20, 2024 6:15 PM

Where has the first Bezier curve gone?

There should be two opposite curves.

If the second one is deleted, the first reappears.

How can I get both at the same time?

include <BOSL2/std.scad>

include <BOSL2/beziers.scad>

w=30;

bezpath = flatten([

bez_begin([-100, 0], 0, 35),

bez_end ([ -20*cos(w), -20*sin(w)], 180+w, 35),

]);

debug_bezier(bezpath);

bezpath = flatten([

bez_begin ([ 20*cos(w), 20*sin(w)], 180+w, -35),

bez_end([100, 0], 0, -35),

]);

debug_bezier(bezpath);

BTW Bezier curves deviate slightly from the tangents, the tangents seem to be as calculated.

Where has the first Bezier curve gone? There should be two opposite curves. If the second one is deleted, the first reappears. How can I get both at the same time? `include <BOSL2/std.scad>` `include <BOSL2/beziers.scad>` `w=30;` `bezpath = flatten([` `bez_begin([-100, 0], 0, 35),` `bez_end ([ -20*cos(w), -20*sin(w)], 180+w, 35),` `]);` `debug_bezier(bezpath);` `bezpath = flatten([` `bez_begin ([ 20*cos(w), 20*sin(w)], 180+w, -35),` `bez_end([100, 0], 0, -35),` `]);` `debug_bezier(bezpath);` BTW Bezier curves deviate slightly from the tangents, the tangents seem to be as calculated.
NH
nop head
Sun, Oct 20, 2024 6:19 PM

Perhaps use a different variable name for the second one.

On Sun, 20 Oct 2024 at 19:15, Caddiy via Discuss discuss@lists.openscad.org
wrote:

Where has the first Bezier curve gone?

There should be two opposite curves.

If the second one is deleted, the first reappears.

How can I get both at the same time?

include <BOSL2/std.scad>

include <BOSL2/beziers.scad>

w=30;

bezpath = flatten([

bez_begin([-100, 0], 0, 35),

bez_end ([ -20cos(w), -20sin(w)], 180+w, 35),

]);

debug_bezier(bezpath);

bezpath = flatten([

bez_begin ([ 20cos(w), 20sin(w)], 180+w, -35),

bez_end([100, 0], 0, -35),

]);

debug_bezier(bezpath);

BTW Bezier curves deviate slightly from the tangents, the tangents seem to
be as calculated.


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

Perhaps use a different variable name for the second one. On Sun, 20 Oct 2024 at 19:15, Caddiy via Discuss <discuss@lists.openscad.org> wrote: > Where has the first Bezier curve gone? > > There should be two opposite curves. > > If the second one is deleted, the first reappears. > > How can I get both at the same time? > > include <BOSL2/std.scad> > > include <BOSL2/beziers.scad> > > w=30; > > bezpath = flatten([ > > bez_begin([-100, 0], 0, 35), > > bez_end ([ -20*cos(w), -20*sin(w)], 180+w, 35), > > ]); > > debug_bezier(bezpath); > > bezpath = flatten([ > > bez_begin ([ 20*cos(w), 20*sin(w)], 180+w, -35), > > bez_end([100, 0], 0, -35), > > ]); > > debug_bezier(bezpath); > > BTW Bezier curves deviate slightly from the tangents, the tangents seem to > be as calculated. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
M
mikeonenine@web.de
Sun, Oct 20, 2024 6:37 PM

nop head wrote:

Perhaps use a different variable name for the second one.

On Sun, 20 Oct 2024 at 19:15, Caddiy via Discuss discuss@lists.openscad.org
wrote:

Where has the first Bezier curve gone?

There should be two opposite curves.

If the second one is deleted, the first reappears.

How can I get both at the same time?

include <BOSL2/std.scad>

include <BOSL2/beziers.scad>

w=30;

bezpath = flatten([

bez_begin([-100, 0], 0, 35),

bez_end ([ -20cos(w), -20sin(w)], 180+w, 35),

]);

debug_bezier(bezpath);

bezpath = flatten([

bez_begin ([ 20cos(w), 20sin(w)], 180+w, -35),

bez_end([100, 0], 0, -35),

]);

debug_bezier(bezpath);

BTW Bezier curves deviate slightly from the tangents, the tangents seem to
be as calculated.


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

Nah, doesn’t help.

include <BOSL2/std.scad>

include <BOSL2/beziers.scad>

x=30;

bezpath = flatten([

bez_begin([-100, 0], 0, 35),

bez_end ([ -20*cos(30), -20*sin(30)], 180+30, 35),

]);

debug_bezier(bezpath);

w=30;

bezpath = flatten([

bez_begin ([ 20*cos(30), 20*sin(30)], 180+30, -35),

bez_end([100, 0], 0, -35),

]);

debug_bezier(bezpath);

nop head wrote: > Perhaps use a different variable name for the second one. > > On Sun, 20 Oct 2024 at 19:15, Caddiy via Discuss [discuss@lists.openscad.org](mailto:discuss@lists.openscad.org) > wrote: > > > Where has the first Bezier curve gone? > > > > There should be two opposite curves. > > > > If the second one is deleted, the first reappears. > > > > How can I get both at the same time? > > > > include <BOSL2/std.scad> > > > > include <BOSL2/beziers.scad> > > > > w=30; > > > > bezpath = flatten(\[ > > > > bez_begin(\[-100, 0\], 0, 35), > > > > bez_end (\[ -20*cos(w), -20*sin(w)\], 180+w, 35), > > > > \]); > > > > debug_bezier(bezpath); > > > > bezpath = flatten(\[ > > > > bez_begin (\[ 20*cos(w), 20*sin(w)\], 180+w, -35), > > > > bez_end(\[100, 0\], 0, -35), > > > > \]); > > > > debug_bezier(bezpath); > > > > BTW Bezier curves deviate slightly from the tangents, the tangents seem to > > be as calculated. > > > > --- > > > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org Nah, doesn’t help. `include <BOSL2/std.scad>` `include <BOSL2/beziers.scad>` `x=30;` `bezpath = flatten([` `bez_begin([-100, 0], 0, 35),` `bez_end ([ -20*cos(30), -20*sin(30)], 180+30, 35),` `]);` `debug_bezier(bezpath);` `w=30;` `bezpath = flatten([` `bez_begin ([ 20*cos(30), 20*sin(30)], 180+30, -35),` `bez_end([100, 0], 0, -35),` `]);` `debug_bezier(bezpath);`
NH
nop head
Sun, Oct 20, 2024 7:07 PM

You are using bezpath for both curves. A variable only has one value in
open scad so it will draw the second curve twice.

On Sun, 20 Oct 2024, 19:37 Caddiy via Discuss, discuss@lists.openscad.org
wrote:

nop head wrote:

Perhaps use a different variable name for the second one.

On Sun, 20 Oct 2024 at 19:15, Caddiy via Discuss
discuss@lists.openscad.org wrote:

Where has the first Bezier curve gone?

There should be two opposite curves.

If the second one is deleted, the first reappears.

How can I get both at the same time?

include <BOSL2/std.scad>

include <BOSL2/beziers.scad>

w=30;

bezpath = flatten([

bez_begin([-100, 0], 0, 35),

bez_end ([ -20cos(w), -20sin(w)], 180+w, 35),

]);

debug_bezier(bezpath);

bezpath = flatten([

bez_begin ([ 20cos(w), 20sin(w)], 180+w, -35),

bez_end([100, 0], 0, -35),

]);

debug_bezier(bezpath);

BTW Bezier curves deviate slightly from the tangents, the tangents seem to
be as calculated.

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

Nah, doesn’t help.

include <BOSL2/std.scad>

include <BOSL2/beziers.scad>

x=30;

bezpath = flatten([

bez_begin([-100, 0], 0, 35),

bez_end ([ -20cos(30), -20sin(30)], 180+30, 35),

]);

debug_bezier(bezpath);

w=30;

bezpath = flatten([

bez_begin ([ 20cos(30), 20sin(30)], 180+30, -35),

bez_end([100, 0], 0, -35),

]);

debug_bezier(bezpath);


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

You are using bezpath for both curves. A variable only has one value in open scad so it will draw the second curve twice. On Sun, 20 Oct 2024, 19:37 Caddiy via Discuss, <discuss@lists.openscad.org> wrote: > nop head wrote: > > Perhaps use a different variable name for the second one. > > On Sun, 20 Oct 2024 at 19:15, Caddiy via Discuss > discuss@lists.openscad.org wrote: > > Where has the first Bezier curve gone? > > There should be two opposite curves. > > If the second one is deleted, the first reappears. > > How can I get both at the same time? > > include <BOSL2/std.scad> > > include <BOSL2/beziers.scad> > > w=30; > > bezpath = flatten([ > > bez_begin([-100, 0], 0, 35), > > bez_end ([ -20*cos(w), -20*sin(w)], 180+w, 35), > > ]); > > debug_bezier(bezpath); > > bezpath = flatten([ > > bez_begin ([ 20*cos(w), 20*sin(w)], 180+w, -35), > > bez_end([100, 0], 0, -35), > > ]); > > debug_bezier(bezpath); > > BTW Bezier curves deviate slightly from the tangents, the tangents seem to > be as calculated. > ------------------------------ > > OpenSCAD mailing list To unsubscribe send an email to > discuss-leave@lists.openscad.org > > Nah, doesn’t help. > > include <BOSL2/std.scad> > > include <BOSL2/beziers.scad> > > x=30; > > bezpath = flatten([ > > bez_begin([-100, 0], 0, 35), > > bez_end ([ -20*cos(30), -20*sin(30)], 180+30, 35), > > ]); > > debug_bezier(bezpath); > > w=30; > > bezpath = flatten([ > > bez_begin ([ 20*cos(30), 20*sin(30)], 180+30, -35), > > bez_end([100, 0], 0, -35), > > ]); > > debug_bezier(bezpath); > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sun, Oct 20, 2024 7:36 PM

On 10/20/2024 12:07 PM, nop head via Discuss wrote:

You are using bezpath for both curves. A variable only has one value
in open scad so it will draw the second curve twice.

... and should have given a WARNING message.

Advice:  turn on Edit  / Preferences / Advanced / OpenSCAD Language
Features / Warnings / Stop on the first warning.  And then fix every
warning.

On 10/20/2024 12:07 PM, nop head via Discuss wrote: > > You are using bezpath for both curves. A variable only has one value > in open scad so it will draw the second curve twice. > ... and should have given a WARNING message. Advice:  turn on Edit  / Preferences / Advanced / OpenSCAD Language Features / Warnings / Stop on the first warning.  And then fix every warning.
NH
nop head
Sun, Oct 20, 2024 7:39 PM

Not sure repeat use of variables gives a warning in the last release. It
certainly does in the snapshots.

On Sun, 20 Oct 2024, 20:36 Jordan Brown, openscad@jordan.maileater.net
wrote:

On 10/20/2024 12:07 PM, nop head via Discuss wrote:

You are using bezpath for both curves. A variable only has one value in
open scad so it will draw the second curve twice.

... and should have given a WARNING message.

Advice:  turn on Edit  / Preferences / Advanced / OpenSCAD Language
Features / Warnings / Stop on the first warning.  And then fix every
warning.

Not sure repeat use of variables gives a warning in the last release. It certainly does in the snapshots. On Sun, 20 Oct 2024, 20:36 Jordan Brown, <openscad@jordan.maileater.net> wrote: > On 10/20/2024 12:07 PM, nop head via Discuss wrote: > > You are using bezpath for both curves. A variable only has one value in > open scad so it will draw the second curve twice. > > > ... and should have given a WARNING message. > > Advice: turn on Edit / Preferences / Advanced / OpenSCAD Language > Features / Warnings / Stop on the first warning. And then fix every > warning. >
JB
Jordan Brown
Sun, Oct 20, 2024 7:41 PM

On 10/20/2024 12:39 PM, nop head wrote:

Not sure repeat use of variables gives a warning in the last release.
It certainly does in the snapshots.

Why I keep a copy of 2021.01 around... yes, it does.

On 10/20/2024 12:39 PM, nop head wrote: > > Not sure repeat use of variables gives a warning in the last release. > It certainly does in the snapshots. > Why I keep a copy of 2021.01 around... yes, it does.
M
mikeonenine@web.de
Sun, Oct 20, 2024 7:47 PM

Ah, now i understand, each Bezier needs an individual name and that is called a variable.

Not like a square or circle, more like a module.

Thanx.

Ah, now i understand, each Bezier needs an individual name and that is called a variable. Not like a square or circle, more like a module. Thanx.
JB
Jordan Brown
Sun, Oct 20, 2024 8:37 PM

On 10/20/2024 12:47 PM, Caddiy via Discuss wrote:

Ah, now i understand, each Bezier needs an individual name and that is
called a variable.

Not like a square or circle, more like a module.

Uh... no, or not exactly.

[ The following is a bit simplified and therefore wrong.  I'll elaborate
at the end. ]

Every value needs its own name, whether that value is a number, a
string, or some more complex construct like a BOSL2 Bézier path or a
BOSL2 VNF.

Core OpenSCAD squares and circles are modules, not values, and so can't
go into variables at all.  BOSL2 has "square" and "circle" functions
that return lists of points.  Those are values and can go into variables.

OpenSCAD modules do not yield values and so can't go into variables.

OpenSCAD doesn't let you assign the same variable twice, no matter what
you're putting into it.

x = 1;
x = 2;

y = "hello";
y = 123;

z = square(10);
z = circle(10);

are all bad.  In core OpenSCAD, the "z" example is doubly illegal,
because core OpenSCAD does not have square() and circle() functions; it
only has square and circle modules.

[ More advanced and correct, though still not completely correct. ]

That "no duplication" rule is inside one "scope".  Very roughly, braces
start a new scope.  Thus this is OK:

x = 1;
if (something) {
    x = 2;
    echo(x);
}
echo(x);

and will yield

ECHO: 2
ECHO: 1

because the inner assignment creates a new x that then vanishes at the
close brace, revealing the original.

[ Getting pretty close to complete truth. ]

Naked braces, that are not a child of an operator, do not start new scopes.

x = 1;
{
    x = 2;
}

is not legal.  (Which seems like a misfeature; see issue 5386
https://github.com/openscad/openscad/issues/5386.)

"include<>" has sort of scope-like behavior; it's OK to set a variable
in an included file and then override it in the "parent" file. 
Similarly for command-line (and Customizer, I think) settings; they can
duplicate in-file settings and override them.

On 10/20/2024 12:47 PM, Caddiy via Discuss wrote: > > Ah, now i understand, each Bezier needs an individual name and that is > called a variable. > > Not like a square or circle, more like a module. > Uh... no, or not exactly. [ The following is a bit simplified and therefore wrong.  I'll elaborate at the end. ] Every value needs its own name, whether that value is a number, a string, or some more complex construct like a BOSL2 Bézier path or a BOSL2 VNF. Core OpenSCAD squares and circles are modules, not values, and so can't go into variables at all.  BOSL2 has "square" and "circle" functions that return lists of points.  Those are values and can go into variables. OpenSCAD modules do not yield values and so can't go into variables. OpenSCAD doesn't let you assign the same variable twice, no matter what you're putting into it. x = 1; x = 2; y = "hello"; y = 123; z = square(10); z = circle(10); are all bad.  In core OpenSCAD, the "z" example is doubly illegal, because core OpenSCAD does not have square() and circle() functions; it only has square and circle modules. [ More advanced and correct, though still not completely correct. ] That "no duplication" rule is inside one "scope".  Very roughly, braces start a new scope.  Thus this is OK: x = 1; if (something) { x = 2; echo(x); } echo(x); and will yield ECHO: 2 ECHO: 1 because the inner assignment creates a *new* x that then vanishes at the close brace, revealing the original. [ Getting pretty close to complete truth. ] Naked braces, that are not a child of an operator, do not start new scopes. x = 1; { x = 2; } is not legal.  (Which seems like a misfeature; see issue 5386 <https://github.com/openscad/openscad/issues/5386>.) "include<>" has sort of scope-like behavior; it's OK to set a variable in an included file and then override it in the "parent" file.  Similarly for command-line (and Customizer, I think) settings; they can duplicate in-file settings and override them.
M
mikeonenine@web.de
Sun, Oct 20, 2024 9:24 PM

Jordan Brown wrote:

On 10/20/2024 12:47 PM, Caddiy via Discuss wrote:

Ah, now i understand, each Bezier needs an individual name and that is
called a variable.

Not like a square or circle, more like a module.

Uh... no, or not exactly.

[ The following is a bit simplified and therefore wrong.  I'll elaborate
at the end. ]

Every value needs its own name, whether that value is a number, a
string, or some more complex construct like a BOSL2 Bézier path or a
BOSL2 VNF.

Core OpenSCAD squares and circles are modules, not values, and so can't
go into variables at all.  BOSL2 has "square" and "circle" functions
that return lists of points.  Those are values and can go into variables.

OpenSCAD modules do not yield values and so can't go into variables.

OpenSCAD doesn't let you assign the same variable twice, no matter what
you're putting into it.

x = 1;
x = 2;

y = "hello";
y = 123;

z = square(10);
z = circle(10);

are all bad.  In core OpenSCAD, the "z" example is doubly illegal,
because core OpenSCAD does not have square() and circle() functions; it
only has square and circle modules.

[ More advanced and correct, though still not completely correct. ]

That "no duplication" rule is inside one "scope".  Very roughly, braces
start a new scope.  Thus this is OK:

x = 1;
if (something) {
    x = 2;
    echo(x);
}
echo(x);

and will yield

ECHO: 2
ECHO: 1

because the inner assignment creates a new x that then vanishes at the
close brace, revealing the original.

[ Getting pretty close to complete truth. ]

Naked braces, that are not a child of an operator, do not start new scopes.

x = 1;
{
    x = 2;
}

is not legal.  (Which seems like a misfeature; see issue 5386
https://github.com/openscad/openscad/issues/5386.)

"include<>" has sort of scope-like behavior; it's OK to set a variable
in an included file and then override it in the "parent" file. 
Similarly for command-line (and Customizer, I think) settings; they can
duplicate in-file settings and override them.

Well yes, obviously. That’s why i said more like a module, not like a module.

The next thing for me is to turn my Bezier curves from the xy-plane to the xz-plane and then do the yz-plane (which is sort of cosinusoidal) so that everything is around the z-axis. Then it will be possible to rotate the whole lot as a module once to the x-axis and once to the y-axis (with a phase difference between the axes of $t*90).

At the moment there are some values that would seem to need to be xyz coordinates in square brackets, but the Bezier expressions don’t want to do that. I may have some questions.

Jordan Brown wrote: > On 10/20/2024 12:47 PM, Caddiy via Discuss wrote: > > > Ah, now i understand, each Bezier needs an individual name and that is > > called a variable. > > > > Not like a square or circle, more like a module. > > Uh... no, or not exactly. > > \[ The following is a bit simplified and therefore wrong.  I'll elaborate > at the end. \] > > Every value needs its own name, whether that value is a number, a > string, or some more complex construct like a BOSL2 Bézier path or a > BOSL2 VNF. > > Core OpenSCAD squares and circles are modules, not values, and so can't > go into variables at all.  BOSL2 has "square" and "circle" functions > that return lists of points.  Those are values and can go into variables. > > OpenSCAD modules do not yield values and so can't go into variables. > > OpenSCAD doesn't let you assign the same variable twice, no matter what > you're putting into it. > > ``` > x = 1; > x = 2; > > y = "hello"; > y = 123; > > z = square(10); > z = circle(10); > ``` > > are all bad.  In core OpenSCAD, the "z" example is doubly illegal, > because core OpenSCAD does not have square() and circle() functions; it > only has square and circle modules. > > \[ More advanced and correct, though still not completely correct. \] > > That "no duplication" rule is inside one "scope".  Very roughly, braces > start a new scope.  Thus this is OK: > > ``` > x = 1; > if (something) { > x = 2; > echo(x); > } > echo(x); > ``` > > and will yield > > ``` > ECHO: 2 > ECHO: 1 > ``` > > because the inner assignment creates a *new* x that then vanishes at the > close brace, revealing the original. > > \[ Getting pretty close to complete truth. \] > > Naked braces, that are not a child of an operator, do not start new scopes. > > ``` > x = 1; > { > x = 2; > } > ``` > > is not legal.  (Which seems like a misfeature; see issue 5386 > <https://github.com/openscad/openscad/issues/5386>.) > > "include<>" has sort of scope-like behavior; it's OK to set a variable > in an included file and then override it in the "parent" file.  > Similarly for command-line (and Customizer, I think) settings; they can > duplicate in-file settings and override them. Well yes, obviously. That’s why i said more like a module, not like a module. The next thing for me is to turn my Bezier curves from the xy-plane to the xz-plane and then do the yz-plane (which is sort of cosinusoidal) so that everything is around the z-axis. Then it will be possible to rotate the whole lot as a module once to the x-axis and once to the y-axis (with a phase difference between the axes of $t\*90). At the moment there are some values that would seem to need to be xyz coordinates in square brackets, but the Bezier expressions don’t want to do that. I may have some questions.