WF
William F. Adams
Sun, Aug 17, 2025 1:32 PM
Okay, given a polygon definition:
if we rotate it, we get:
which has the ball inverted inside the bottom:
How does that happen?!?
Also, is there a possibility of adding support for arcs in the 2D subsystem? It's a pain positioning circles and doing intersections and so forth.
Or, could Bézier curves be added?
I am going to try to re-create all this in "pure" OpenSCAD just to check, but I can't see a reason for it to be dfferent in (Open)PythonSCAD.
William
Okay, given a polygon definition:
if we rotate it, we get:
which has the ball inverted inside the bottom:
How does that happen?!?
Also, is there a possibility of adding support for arcs in the 2D subsystem? It's a pain positioning circles and doing intersections and so forth.
Or, could Bézier curves be added?
I am going to try to re-create all this in "pure" OpenSCAD just to check, but I can't see a reason for it to be dfferent in (Open)PythonSCAD.
William
WF
William F. Adams
Sun, Aug 17, 2025 1:45 PM
And after experimenting a bit, I see that I was shifting things in the wrong direction:
//!OpenSCAD
$fn=90;
module square_tool_profile() {
square([1.5875, 12.7], center=false);
}
module ball_tool_profile() {
union(){
intersection() {
translate([0, (1.5875 / 2), 0]){
circle(r=(1.5875 / 2));
square([(1.5875 / 2), (12.7 - 1.5875 / 2)], center=false);
}
square([1.5875, 12.7], center=false);
}
translate([0, 12.7, 0]){
square([3.175, 12.7], center=false);
}
}
}
rotate_extrude($fn=90){
ball_tool_profile();}
That said, I'm still mystified as to how the inverted thing happened, and if someone has an explanation/example for it, I would be glad of that.
William
And after experimenting a bit, I see that I was shifting things in the wrong direction:
//!OpenSCAD
$fn=90;
module square_tool_profile() {
square([1.5875, 12.7], center=false);
}
module ball_tool_profile() {
union(){
intersection() {
translate([0, (1.5875 / 2), 0]){
circle(r=(1.5875 / 2));
square([(1.5875 / 2), (12.7 - 1.5875 / 2)], center=false);
}
square([1.5875, 12.7], center=false);
}
translate([0, 12.7, 0]){
square([3.175, 12.7], center=false);
}
}
}
rotate_extrude($fn=90){
ball_tool_profile();}
That said, I'm still mystified as to how the inverted thing happened, and if someone has an explanation/example for it, I would be glad of that.
William
WF
William F. Adams
Sun, Aug 17, 2025 1:53 PM
Except, I now remember why I was doing the shifting --- when the toolprofile is:
the rotate extruded toolshape is:
which is missing the ball shape at the bottom....
William
Except, I now remember why I was doing the shifting --- when the toolprofile is:
the rotate extruded toolshape is:
which is missing the ball shape at the bottom....
William
JB
Jon Bondy
Sun, Aug 17, 2025 2:05 PM
Is this an OpenSCAD question or a PythonSCAD question?
On 8/17/2025 9:53 AM, William F. Adams via Discuss wrote:
Except, I now remember why I was doing the shifting --- when the
toolprofile is:
Inline image
the rotate extruded toolshape is:
Inline image
which is missing the ball shape at the bottom....
William
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
Is this an OpenSCAD question or a PythonSCAD question?
On 8/17/2025 9:53 AM, William F. Adams via Discuss wrote:
> Except, I now remember why I was doing the shifting --- when the
> toolprofile is:
>
> Inline image
>
> the rotate extruded toolshape is:
>
> Inline image
>
> which is missing the ball shape at the bottom....
>
> William
>
>
> _______________________________________________
> 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
WF
William F. Adams
Sun, Aug 17, 2025 3:33 PM
On Sunday, August 17, 2025 at 10:05:49 AM EDT, Jon Bondy jon@jonbondy.com wrote:
Is this an OpenSCAD question or a PythonSCAD question?
Good point.
I thought this aspect was equivalent for both, but maybe it isn't.
Digging deeper now.
William
On Sunday, August 17, 2025 at 10:05:49 AM EDT, Jon Bondy <jon@jonbondy.com> wrote:
>Is this an OpenSCAD question or a PythonSCAD question?
Good point.
I thought this aspect was equivalent for both, but maybe it isn't.
Digging deeper now.
William
SP
Sanjeev Prabhakar
Sun, Aug 17, 2025 5:01 PM
Can you share the coordinates of the 2d shapes which you want to rotate
extrude.
On Sun, 17 Aug, 2025, 7:23 pm William F. Adams via Discuss, <
discuss@lists.openscad.org> wrote:
Except, I now remember why I was doing the shifting --- when the
toolprofile is:
[image: Inline image]
the rotate extruded toolshape is:
[image: Inline image]
which is missing the ball shape at the bottom....
William
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Can you share the coordinates of the 2d shapes which you want to rotate
extrude.
On Sun, 17 Aug, 2025, 7:23 pm William F. Adams via Discuss, <
discuss@lists.openscad.org> wrote:
> Except, I now remember why I was doing the shifting --- when the
> toolprofile is:
>
> [image: Inline image]
>
> the rotate extruded toolshape is:
>
> [image: Inline image]
>
> which is missing the ball shape at the bottom....
>
> William
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Mon, Aug 18, 2025 12:12 PM
On 8/17/2025 3:32 PM, William F. Adams via Discuss wrote:
I agree that it looks wrong, but absent the program that generates it,
it's hard to tell what's wrong. If you can supply the rotate_extrude()
and polygon() calls, I expect that the answer will be somewhat obvious.
I haven't tried using PythonSCAD, but you might be able to use the "View
CSG" feature to extract the primitive OpenSCAD geometry operations.
Also, is there a possibility of adding support for arcs in the 2D
subsystem?
Remember that the 2D subsystem only handles "filled" 2D shapes; it
doesn't handle 1D-in-2D shapes like unfilled arcs.
If what you want is really a pie slice or something similar, I would
write module that generates a desired pie slice, whether by differencing
or intersecting circles or by directly generating a polygon, and use
that as a cookie cutter for modifying whatever shape you want to be
arc-shaped. Without looking, I wouldn't be at all surprised if BOSL2
offers that module already.
Or, could Bézier curves be added?
Again, a Bézier curve per se would require a significant change in the
subsystem. What you generally want today is a polygon composed of
several connected Bézier curves. BOSL2 has functions to generate the
lists of points. If you want to DIY, the calculation is complex for
non-math types, but it's only a couple of lines. I copied it from
somewhere else. Source at the bottom.
There is a very real question of whether we should put such things into
the core (where they are immediately available to everybody, but they
take up namespace and are in C++, which is harder to write, harder to
maintain, and fails catastrophically), or should be left to libraries.
// Bezier functions fromhttps://www.thingiverse.com/thing:8443
// but that yielded either single points or a raft of triangles;
// this yields a vector of points that you can then concatenate
// with other pieces to form a single polygon.
// If we were really clever, I think it would be possible to
// automatically space the output points based on how linear
// the curve is at that point. But right now I'm not that clever.
function BEZ03(u) = pow((1-u), 3);
function BEZ13(u) = 3u(pow((1-u),2));
function BEZ23(u) = 3*(pow(u,2))*(1-u);
function BEZ33(u) = pow(u,3);
function PointAlongBez4(p0, p1, p2, p3, u) = [
BEZ03(u)*p0[0]+BEZ13(u)*p1[0]+BEZ23(u)*p2[0]+BEZ33(u)*p3[0],
BEZ03(u)*p0[1]+BEZ13(u)*p1[1]+BEZ23(u)*p2[1]+BEZ33(u)*p3[1]];
// p0 - start point
// p1 - control point 1, line departs p0 headed this way
// p2 - control point 2, line arrives at p3 from this way
// p3 - end point
// segs - number of segments
function bez(p0, p1, p2, p3, segs) = [
for (i = [0:segs]) PointAlongBez4(p0, p1, p2, p3, i/segs)
];
On 8/17/2025 3:32 PM, William F. Adams via Discuss wrote:
> How does that happen?!?
I agree that it looks wrong, but absent the program that generates it,
it's hard to tell what's wrong. If you can supply the rotate_extrude()
and polygon() calls, I expect that the answer will be somewhat obvious.
I haven't tried using PythonSCAD, but you might be able to use the "View
CSG" feature to extract the primitive OpenSCAD geometry operations.
> Also, is there a possibility of adding support for arcs in the 2D
> subsystem?
Remember that the 2D subsystem only handles "filled" 2D shapes; it
doesn't handle 1D-in-2D shapes like unfilled arcs.
If what you want is really a pie slice or something similar, I would
write module that generates a desired pie slice, whether by differencing
or intersecting circles or by directly generating a polygon, and use
that as a cookie cutter for modifying whatever shape you want to be
arc-shaped. Without looking, I wouldn't be at all surprised if BOSL2
offers that module already.
> Or, could Bézier curves be added?
Again, a Bézier curve per se would require a significant change in the
subsystem. What you generally want today is a polygon composed of
several connected Bézier curves. BOSL2 has functions to generate the
lists of points. If you want to DIY, the calculation is complex for
non-math types, but it's only a couple of lines. I copied it from
somewhere else. Source at the bottom.
There is a very real question of whether we should put such things into
the core (where they are immediately available to everybody, but they
take up namespace and are in C++, which is harder to write, harder to
maintain, and fails catastrophically), or should be left to libraries.
// Bezier functions fromhttps://www.thingiverse.com/thing:8443
// but that yielded either single points or a raft of triangles;
// this yields a vector of points that you can then concatenate
// with other pieces to form a single polygon.
// If we were really clever, I think it would be possible to
// automatically space the output points based on how linear
// the curve is at that point. But right now I'm not that clever.
function BEZ03(u) = pow((1-u), 3);
function BEZ13(u) = 3*u*(pow((1-u),2));
function BEZ23(u) = 3*(pow(u,2))*(1-u);
function BEZ33(u) = pow(u,3);
function PointAlongBez4(p0, p1, p2, p3, u) = [
BEZ03(u)*p0[0]+BEZ13(u)*p1[0]+BEZ23(u)*p2[0]+BEZ33(u)*p3[0],
BEZ03(u)*p0[1]+BEZ13(u)*p1[1]+BEZ23(u)*p2[1]+BEZ33(u)*p3[1]];
// p0 - start point
// p1 - control point 1, line departs p0 headed this way
// p2 - control point 2, line arrives at p3 from this way
// p3 - end point
// segs - number of segments
function bez(p0, p1, p2, p3, segs) = [
for (i = [0:segs]) PointAlongBez4(p0, p1, p2, p3, i/segs)
];
JB
Jordan Brown
Mon, Aug 18, 2025 12:23 PM
[ Sorry about the somewhat-stale previous reply; I'm catching up and
tried to read ahead before responding, but failed. ]
On 8/17/2025 3:53 PM, William F. Adams via Discuss wrote:
Except, I now remember why I was doing the shifting --- when the
toolprofile is:
[...]
which is missing the ball shape at the bottom....
Looking at those two images, the first of which matches the
OpenSCAD-language program you sent, that second image certainly
shouldn't be the result of a rotate_extrude on the first. (And with
the OpenSCAD-language program, I get the correct result.)
I'd suggest pulling the raw PythonSCAD operations out of your larger
library, so that you can have a standalone PythonSCAD program that
yields this shape, and if that looks correct and doesn't extrude
properly, port it over to OpenSCAD-language and check it there.
[ Sorry about the somewhat-stale previous reply; I'm catching up and
tried to read ahead before responding, but failed. ]
On 8/17/2025 3:53 PM, William F. Adams via Discuss wrote:
> Except, I now remember why I was doing the shifting --- when the
> toolprofile is:
> [...]
> which is missing the ball shape at the bottom....
Looking at those two images, the first of which matches the
OpenSCAD-language program you sent, that second image certainly
*shouldn't* be the result of a rotate_extrude on the first. (And with
the OpenSCAD-language program, I get the correct result.)
I'd suggest pulling the raw PythonSCAD operations out of your larger
library, so that you can have a standalone PythonSCAD program that
yields this shape, and if that looks correct and doesn't extrude
properly, port it over to OpenSCAD-language and check it there.
JB
Jon Bondy
Mon, Aug 18, 2025 12:25 PM
BOSL2 has all of the bezier stuff, as well as a 2D turtle. Why add any
of this to OpenSCAD itself? The language should be lean and mean.
On 8/18/2025 8:12 AM, Jordan Brown via Discuss wrote:
On 8/17/2025 3:32 PM, William F. Adams via Discuss wrote:
I agree that it looks wrong, but absent the program that generates it,
it's hard to tell what's wrong. If you can supply the
rotate_extrude() and polygon() calls, I expect that the answer will be
somewhat obvious.
I haven't tried using PythonSCAD, but you might be able to use the
"View CSG" feature to extract the primitive OpenSCAD geometry operations.
Also, is there a possibility of adding support for arcs in the 2D
subsystem?
Remember that the 2D subsystem only handles "filled" 2D shapes; it
doesn't handle 1D-in-2D shapes like unfilled arcs.
If what you want is really a pie slice or something similar, I would
write module that generates a desired pie slice, whether by
differencing or intersecting circles or by directly generating a
polygon, and use that as a cookie cutter for modifying whatever shape
you want to be arc-shaped. Without looking, I wouldn't be at all
surprised if BOSL2 offers that module already.
Or, could Bézier curves be added?
Again, a Bézier curve per se would require a significant change in the
subsystem. What you generally want today is a polygon composed of
several connected Bézier curves. BOSL2 has functions to generate the
lists of points. If you want to DIY, the calculation is complex for
non-math types, but it's only a couple of lines. I copied it from
somewhere else. Source at the bottom.
There is a very real question of whether we should put such things
into the core (where they are immediately available to everybody, but
they take up namespace and are in C++, which is harder to write,
harder to maintain, and fails catastrophically), or should be left to
libraries.
// Bezier functions fromhttps://www.thingiverse.com/thing:8443
// but that yielded either single points or a raft of triangles;
// this yields a vector of points that you can then concatenate
// with other pieces to form a single polygon.
// If we were really clever, I think it would be possible to
// automatically space the output points based on how linear
// the curve is at that point. But right now I'm not that clever.
function BEZ03(u) = pow((1-u), 3);
function BEZ13(u) = 3u(pow((1-u),2));
function BEZ23(u) = 3*(pow(u,2))*(1-u);
function BEZ33(u) = pow(u,3);
function PointAlongBez4(p0, p1, p2, p3, u) = [
BEZ03(u)*p0[0]+BEZ13(u)*p1[0]+BEZ23(u)*p2[0]+BEZ33(u)*p3[0],
BEZ03(u)*p0[1]+BEZ13(u)*p1[1]+BEZ23(u)*p2[1]+BEZ33(u)*p3[1]];
// p0 - start point
// p1 - control point 1, line departs p0 headed this way
// p2 - control point 2, line arrives at p3 from this way
// p3 - end point
// segs - number of segments
function bez(p0, p1, p2, p3, segs) = [
for (i = [0:segs]) PointAlongBez4(p0, p1, p2, p3, i/segs)
];
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
BOSL2 has all of the bezier stuff, as well as a 2D turtle. Why add any
of this to OpenSCAD itself? The language should be lean and mean.
On 8/18/2025 8:12 AM, Jordan Brown via Discuss wrote:
> On 8/17/2025 3:32 PM, William F. Adams via Discuss wrote:
>> How does that happen?!?
>
> I agree that it looks wrong, but absent the program that generates it,
> it's hard to tell what's wrong. If you can supply the
> rotate_extrude() and polygon() calls, I expect that the answer will be
> somewhat obvious.
>
> I haven't tried using PythonSCAD, but you might be able to use the
> "View CSG" feature to extract the primitive OpenSCAD geometry operations.
>
>> Also, is there a possibility of adding support for arcs in the 2D
>> subsystem?
>
> Remember that the 2D subsystem only handles "filled" 2D shapes; it
> doesn't handle 1D-in-2D shapes like unfilled arcs.
>
> If what you want is really a pie slice or something similar, I would
> write module that generates a desired pie slice, whether by
> differencing or intersecting circles or by directly generating a
> polygon, and use that as a cookie cutter for modifying whatever shape
> you want to be arc-shaped. Without looking, I wouldn't be at all
> surprised if BOSL2 offers that module already.
>
>> Or, could Bézier curves be added?
>
> Again, a Bézier curve per se would require a significant change in the
> subsystem. What you generally want today is a polygon composed of
> several connected Bézier curves. BOSL2 has functions to generate the
> lists of points. If you want to DIY, the calculation is complex for
> non-math types, but it's only a couple of lines. I copied it from
> somewhere else. Source at the bottom.
>
> There is a very real question of whether we should put such things
> into the core (where they are immediately available to everybody, but
> they take up namespace and are in C++, which is harder to write,
> harder to maintain, and fails catastrophically), or should be left to
> libraries.
>
> // Bezier functions fromhttps://www.thingiverse.com/thing:8443
> // but that yielded either single points or a raft of triangles;
> // this yields a vector of points that you can then concatenate
> // with other pieces to form a single polygon.
> // If we were really clever, I think it would be possible to
> // automatically space the output points based on how linear
> // the curve is at that point. But right now I'm not that clever.
> function BEZ03(u) = pow((1-u), 3);
> function BEZ13(u) = 3*u*(pow((1-u),2));
> function BEZ23(u) = 3*(pow(u,2))*(1-u);
> function BEZ33(u) = pow(u,3);
>
> function PointAlongBez4(p0, p1, p2, p3, u) = [
> BEZ03(u)*p0[0]+BEZ13(u)*p1[0]+BEZ23(u)*p2[0]+BEZ33(u)*p3[0],
> BEZ03(u)*p0[1]+BEZ13(u)*p1[1]+BEZ23(u)*p2[1]+BEZ33(u)*p3[1]];
>
> // p0 - start point
> // p1 - control point 1, line departs p0 headed this way
> // p2 - control point 2, line arrives at p3 from this way
> // p3 - end point
> // segs - number of segments
> function bez(p0, p1, p2, p3, segs) = [
> for (i = [0:segs]) PointAlongBez4(p0, p1, p2, p3, i/segs)
> ];
>
> _______________________________________________
> 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
JB
Jordan Brown
Mon, Aug 18, 2025 1:36 PM
On 8/18/2025 2:25 PM, Jon Bondy wrote:
BOSL2 has all of the bezier stuff, as well as a 2D turtle. Why add
any of this to OpenSCAD itself? The language should be lean and mean.
The argument for putting stuff in the core is so that it's available to
everybody, notably to beginners.
One possible answer is to have a library, probably not as extensive as
BOSL2, that is bundled with the application and so always available with
some simple use <stdlib.scad>
or include <stdlib.scad>
. I don't
think we would want to include/use it by default, because of namespace
issues, but it could be readily and universally available.
On 8/18/2025 2:25 PM, Jon Bondy wrote:
>
> BOSL2 has all of the bezier stuff, as well as a 2D turtle. Why add
> any of this to OpenSCAD itself? The language should be lean and mean.
>
The argument for putting stuff in the core is so that it's available to
everybody, notably to beginners.
One possible answer is to have a library, probably not as extensive as
BOSL2, that is bundled with the application and so always available with
some simple `use <stdlib.scad>` or `include <stdlib.scad>`. I don't
think we would want to include/use it by default, because of namespace
issues, but it could be readily and universally available.