discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Super ellipsoid

AM
Adrian Mariano
Sat, Feb 15, 2025 1:21 PM

I think the basic concern that people had about this isn't that it's
"dirty" but that since it's nonsense geometrically, could we have
confidence that this method would always work in the future?  As noted,
this is already in BOSL2 as hull_points() with fast=true.  In the previous
discussion I think people had examples where the run time improvement was
noticeable.

Basically: Is this a supported approach that we can rely on continuing to
work indefinitely?

On Sat, Feb 15, 2025 at 5:22 AM Rudolf parkinbot@digitaldocument.de wrote:

The "hack" came up with OpenSCAD 2015 if I remember well. Even it is
"dirty coding" I use it since then to speed up my personal coding and don't
care whether another solution would speed up my renders from 0:00:00.112
to  0:00:00.82 or so. However, the function might be a candidate for a
new primitive in BOSL2.
Am 15.02.2025 um 01:24 schrieb Adrian Mariano:

I think it's been quite a long time since that hack was discussed here.
One discovery from the last time around is that it's faster (I think
possibly a lot faster) to divide your points into triangles rather than
passing one huge "face".  Maybe it triangulates the face?  This hack is in
BOSL2 as hull_points().

On Fri, Feb 14, 2025 at 5:52 PM Rudolf via Discuss <
discuss@lists.openscad.org> wrote:

Sorry guys to open the theme again, but I can't reply to it, as I wasn't
on the list when it was posted and found the thread on the Empathy web
mirror ...

So, here is my compact code for the super ellipsoid. I used a tricky hull
to display the output. However this obviously only works for convex shapes
i.e. nx, ny, nz values >= 1

points = Superellipse(a=10, b=20, c=30, nx=2, ny=2, nz=2, step=3);

// draw point cloud (hull() works for convex shapes only)
hull() polyhedron(points, [[for(i=[0:len(points)-1]) i]]);

function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2, step=10) =
[ for(u=[-90:step:90], v=[0:step:360])
let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) *
sign(cos(v))pow(abs(cos(v)),2/ny))
let(y = b
sign(cos(u)) *pow(abs(cos(u)),2/nx) *
sign(sin(v))pow(abs(sin(v)),2/ny))
let(z = c
sign(sin(u)) *pow(abs(sin(u)),2/nz))
[x,y,z]
];


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

I think the basic concern that people had about this isn't that it's "dirty" but that since it's nonsense geometrically, could we have confidence that this method would always work in the future? As noted, this is already in BOSL2 as hull_points() with fast=true. In the previous discussion I think people had examples where the run time improvement was noticeable. Basically: Is this a supported approach that we can rely on continuing to work indefinitely? On Sat, Feb 15, 2025 at 5:22 AM Rudolf <parkinbot@digitaldocument.de> wrote: > The "hack" came up with OpenSCAD 2015 if I remember well. Even it is > "dirty coding" I use it since then to speed up my personal coding and don't > care whether another solution would speed up my renders from 0:00:00.112 > to 0:00:00.82 or so. However, the function might be a candidate for a > new primitive in BOSL2. > Am 15.02.2025 um 01:24 schrieb Adrian Mariano: > > I think it's been quite a long time since that hack was discussed here. > One discovery from the last time around is that it's faster (I think > possibly a lot faster) to divide your points into triangles rather than > passing one huge "face". Maybe it triangulates the face? This hack is in > BOSL2 as hull_points(). > > On Fri, Feb 14, 2025 at 5:52 PM Rudolf via Discuss < > discuss@lists.openscad.org> wrote: > >> Sorry guys to open the theme again, but I can't reply to it, as I wasn't >> on the list when it was posted and found the thread on the Empathy web >> mirror ... >> >> So, here is my compact code for the super ellipsoid. I used a tricky hull >> to display the output. However this obviously only works for convex shapes >> i.e. nx, ny, nz values >= 1 >> >> points = Superellipse(a=10, b=20, c=30, nx=2, ny=2, nz=2, step=3); >> >> // draw point cloud (hull() works for convex shapes only) >> hull() polyhedron(points, [[for(i=[0:len(points)-1]) i]]); >> >> function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2, step=10) = >> [ for(u=[-90:step:90], v=[0:step:360]) >> let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) * >> sign(cos(v))*pow(abs(cos(v)),2/ny)) >> let(y = b*sign(cos(u)) *pow(abs(cos(u)),2/nx) * >> sign(sin(v))*pow(abs(sin(v)),2/ny)) >> let(z = c*sign(sin(u)) *pow(abs(sin(u)),2/nz)) >> [x,y,z] >> ]; >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >
R
Rudolf
Sat, Feb 15, 2025 3:22 PM

To make it clear again: It was not at all my intention to discuss the
hack or any BOSL2 implementations of it. We all know and I think I
pointed that out that it is just a one-liner vehicle to display the
result of Superellipse() in a concise way.  My point is that
Superellipse() would be a powerful candidate for a primitive.

Am 15.02.2025 um 14:21 schrieb Adrian Mariano via Discuss:

I think the basic concern that people had about this isn't that it's
"dirty" but that since it's nonsense geometrically, could we have
confidence that this method would always work in the future?   As
noted, this is already in BOSL2 as hull_points() with fast=true.  In
the previous discussion I think people had examples where the run time
improvement was noticeable.

Basically: Is this a supported approach that we can rely on continuing
to work indefinitely?

On Sat, Feb 15, 2025 at 5:22 AM Rudolf parkinbot@digitaldocument.de
wrote:

 The "hack" came up with OpenSCAD 2015 if I remember well. Even it
 is "dirty coding" I use it since then to speed up my personal
 coding and don't care whether another solution would speed up my
 renders from 0:00:00.112 to 0:00:00.82 or so. However, the
 function might be a candidate for a new primitive in BOSL2.

 Am 15.02.2025 um 01:24 schrieb Adrian Mariano:
 I think it's been quite a long time since that hack was discussed
 here.  One discovery from the last time around is that it's
 faster (I think possibly a lot faster) to divide your points into
 triangles rather than passing one huge "face".  Maybe it
 triangulates the face?  This hack is in BOSL2 as hull_points().

 On Fri, Feb 14, 2025 at 5:52 PM Rudolf via Discuss
 <discuss@lists.openscad.org> wrote:

     Sorry guys to open the theme again, but I can't reply to it,
     as I wasn't on the list when it was posted and found the
     thread on the Empathy web mirror ...

     So, here is my compact code for the super ellipsoid. I used a
     tricky hull to display the output. However this obviously
     only works for convex shapes i.e. nx, ny, nz values >= 1

     points = Superellipse(a=10, b=20, c=30, nx=2, ny=2, nz=2,
     step=3);

     // draw point cloud (hull() works for convex shapes only)
     hull() polyhedron(points, [[for(i=[0:len(points)-1]) i]]);

     function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2, step=10) =
     [ for(u=[-90:step:90], v=[0:step:360])
         let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) *
     sign(cos(v))*pow(abs(cos(v)),2/ny))
         let(y = b*sign(cos(u)) *pow(abs(cos(u)),2/nx) *
     sign(sin(v))*pow(abs(sin(v)),2/ny))
         let(z = c*sign(sin(u)) *pow(abs(sin(u)),2/nz))
         [x,y,z]
     ];


     _______________________________________________
     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

To make it clear again: It was not at all my intention to discuss the hack or any BOSL2 implementations of it. We all know and I think I pointed that out that it is just a one-liner vehicle to display the result of Superellipse() in a concise way.  My point is that Superellipse() would be a powerful candidate for a primitive. Am 15.02.2025 um 14:21 schrieb Adrian Mariano via Discuss: > I think the basic concern that people had about this isn't that it's > "dirty" but that since it's nonsense geometrically, could we have > confidence that this method would always work in the future?   As > noted, this is already in BOSL2 as hull_points() with fast=true.  In > the previous discussion I think people had examples where the run time > improvement was noticeable. > > Basically: Is this a supported approach that we can rely on continuing > to work indefinitely? > > On Sat, Feb 15, 2025 at 5:22 AM Rudolf <parkinbot@digitaldocument.de> > wrote: > > The "hack" came up with OpenSCAD 2015 if I remember well. Even it > is "dirty coding" I use it since then to speed up my personal > coding and don't care whether another solution would speed up my > renders from 0:00:00.112 to 0:00:00.82 or so. However, the > function might be a candidate for a new primitive in BOSL2. > > Am 15.02.2025 um 01:24 schrieb Adrian Mariano: >> I think it's been quite a long time since that hack was discussed >> here.  One discovery from the last time around is that it's >> faster (I think possibly a lot faster) to divide your points into >> triangles rather than passing one huge "face".  Maybe it >> triangulates the face?  This hack is in BOSL2 as hull_points(). >> >> On Fri, Feb 14, 2025 at 5:52 PM Rudolf via Discuss >> <discuss@lists.openscad.org> wrote: >> >> Sorry guys to open the theme again, but I can't reply to it, >> as I wasn't on the list when it was posted and found the >> thread on the Empathy web mirror ... >> >> So, here is my compact code for the super ellipsoid. I used a >> tricky hull to display the output. However this obviously >> only works for convex shapes i.e. nx, ny, nz values >= 1 >> >> points = Superellipse(a=10, b=20, c=30, nx=2, ny=2, nz=2, >> step=3); >> >> // draw point cloud (hull() works for convex shapes only) >> hull() polyhedron(points, [[for(i=[0:len(points)-1]) i]]); >> >> function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2, step=10) = >> [ for(u=[-90:step:90], v=[0:step:360]) >>     let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) * >> sign(cos(v))*pow(abs(cos(v)),2/ny)) >>     let(y = b*sign(cos(u)) *pow(abs(cos(u)),2/nx) * >> sign(sin(v))*pow(abs(sin(v)),2/ny)) >>     let(z = c*sign(sin(u)) *pow(abs(sin(u)),2/nz)) >>     [x,y,z] >> ]; >> >> >> _______________________________________________ >> 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
R
Rudolf
Sat, Feb 15, 2025 4:11 PM

I am not a BOSL2 user, but the point cloud can also be constructed to be
easily skinable. So the following formulation of the function will allow
to display the full parameter range of super ellipsoids. (partial)
concave shapes result from nx, ny, or nz <1

include <BOSL2/std.scad>
include <BOSL2/skin.scad>

points = Superellipse(a=5, b=12, c=10, nx=0.5, ny=1.5, nz=1.5, step=3);
skin(points, slices =1, closed=true);

function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2, step=10) =
[
  for(v=[.5:step:359.5])
  [
    for(u=[-90:step:90])
      let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) *
sign(cos(v))pow(abs(cos(v)),2/ny))
      let(y = b
sign(cos(u)) *pow(abs(cos(u)),2/nx) *
sign(sin(v))pow(abs(sin(v)),2/ny))
      let(z = c
sign(sin(u)) *pow(abs(sin(u)),2/nz))
      [x,y,z]
  ]
];

Am 15.02.2025 um 16:22 schrieb Rudolf via Discuss:

To make it clear again: It was not at all my intention to discuss the
hack or any BOSL2 implementations of it. We all know and I think I
pointed that out that it is just a one-liner vehicle to display the
result of Superellipse() in a concise way.  My point is that
Superellipse() would be a powerful candidate for a primitive.

Am 15.02.2025 um 14:21 schrieb Adrian Mariano via Discuss:

I think the basic concern that people had about this isn't that it's
"dirty" but that since it's nonsense geometrically, could we have
confidence that this method would always work in the future?   As
noted, this is already in BOSL2 as hull_points() with fast=true.  In
the previous discussion I think people had examples where the run
time improvement was noticeable.

Basically: Is this a supported approach that we can rely on
continuing to work indefinitely?

On Sat, Feb 15, 2025 at 5:22 AM Rudolf parkinbot@digitaldocument.de
wrote:

 The "hack" came up with OpenSCAD 2015 if I remember well. Even it
 is "dirty coding" I use it since then to speed up my personal
 coding and don't care whether another solution would speed up my
 renders from 0:00:00.112 to 0:00:00.82 or so. However, the
 function might be a candidate for a new primitive in BOSL2.

 Am 15.02.2025 um 01:24 schrieb Adrian Mariano:
 I think it's been quite a long time since that hack was
 discussed here.  One discovery from the last time around is that
 it's faster (I think possibly a lot faster) to divide your
 points into triangles rather than passing one huge "face". 
 Maybe it triangulates the face?  This hack is in BOSL2 as
 hull_points().

 On Fri, Feb 14, 2025 at 5:52 PM Rudolf via Discuss
 <discuss@lists.openscad.org> wrote:

     Sorry guys to open the theme again, but I can't reply to it,
     as I wasn't on the list when it was posted and found the
     thread on the Empathy web mirror ...

     So, here is my compact code for the super ellipsoid. I used
     a tricky hull to display the output. However this obviously
     only works for convex shapes i.e. nx, ny, nz values >= 1

     points = Superellipse(a=10, b=20, c=30, nx=2, ny=2, nz=2,
     step=3);

     // draw point cloud (hull() works for convex shapes only)
     hull() polyhedron(points, [[for(i=[0:len(points)-1]) i]]);

     function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2,
     step=10) =
     [ for(u=[-90:step:90], v=[0:step:360])
         let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) *
     sign(cos(v))*pow(abs(cos(v)),2/ny))
         let(y = b*sign(cos(u)) *pow(abs(cos(u)),2/nx) *
     sign(sin(v))*pow(abs(sin(v)),2/ny))
         let(z = c*sign(sin(u)) *pow(abs(sin(u)),2/nz))
         [x,y,z]
     ];


     _______________________________________________
     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


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

I am not a BOSL2 user, but the point cloud can also be constructed to be easily skinable. So the following formulation of the function will allow to display the full parameter range of super ellipsoids. (partial) concave shapes result from nx, ny, or nz <1 include <BOSL2/std.scad> include <BOSL2/skin.scad> points = Superellipse(a=5, b=12, c=10, nx=0.5, ny=1.5, nz=1.5, step=3); skin(points, slices =1, closed=true); function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2, step=10) = [   for(v=[.5:step:359.5])   [     for(u=[-90:step:90])       let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) * sign(cos(v))*pow(abs(cos(v)),2/ny))       let(y = b*sign(cos(u)) *pow(abs(cos(u)),2/nx) * sign(sin(v))*pow(abs(sin(v)),2/ny))       let(z = c*sign(sin(u)) *pow(abs(sin(u)),2/nz))       [x,y,z]   ] ]; Am 15.02.2025 um 16:22 schrieb Rudolf via Discuss: > > To make it clear again: It was not at all my intention to discuss the > hack or any BOSL2 implementations of it. We all know and I think I > pointed that out that it is just a one-liner vehicle to display the > result of Superellipse() in a concise way.  My point is that > Superellipse() would be a powerful candidate for a primitive. > > Am 15.02.2025 um 14:21 schrieb Adrian Mariano via Discuss: >> I think the basic concern that people had about this isn't that it's >> "dirty" but that since it's nonsense geometrically, could we have >> confidence that this method would always work in the future?   As >> noted, this is already in BOSL2 as hull_points() with fast=true.  In >> the previous discussion I think people had examples where the run >> time improvement was noticeable. >> >> Basically: Is this a supported approach that we can rely on >> continuing to work indefinitely? >> >> On Sat, Feb 15, 2025 at 5:22 AM Rudolf <parkinbot@digitaldocument.de> >> wrote: >> >> The "hack" came up with OpenSCAD 2015 if I remember well. Even it >> is "dirty coding" I use it since then to speed up my personal >> coding and don't care whether another solution would speed up my >> renders from 0:00:00.112 to 0:00:00.82 or so. However, the >> function might be a candidate for a new primitive in BOSL2. >> >> Am 15.02.2025 um 01:24 schrieb Adrian Mariano: >>> I think it's been quite a long time since that hack was >>> discussed here.  One discovery from the last time around is that >>> it's faster (I think possibly a lot faster) to divide your >>> points into triangles rather than passing one huge "face".  >>> Maybe it triangulates the face?  This hack is in BOSL2 as >>> hull_points(). >>> >>> On Fri, Feb 14, 2025 at 5:52 PM Rudolf via Discuss >>> <discuss@lists.openscad.org> wrote: >>> >>> Sorry guys to open the theme again, but I can't reply to it, >>> as I wasn't on the list when it was posted and found the >>> thread on the Empathy web mirror ... >>> >>> So, here is my compact code for the super ellipsoid. I used >>> a tricky hull to display the output. However this obviously >>> only works for convex shapes i.e. nx, ny, nz values >= 1 >>> >>> points = Superellipse(a=10, b=20, c=30, nx=2, ny=2, nz=2, >>> step=3); >>> >>> // draw point cloud (hull() works for convex shapes only) >>> hull() polyhedron(points, [[for(i=[0:len(points)-1]) i]]); >>> >>> function Superellipse(a=1, b=1, c=1, nx=2, ny=2, nz=2, >>> step=10) = >>> [ for(u=[-90:step:90], v=[0:step:360]) >>>     let(x = a*sign(cos(u)) *pow(abs(cos(u)),2/nx) * >>> sign(cos(v))*pow(abs(cos(v)),2/ny)) >>>     let(y = b*sign(cos(u)) *pow(abs(cos(u)),2/nx) * >>> sign(sin(v))*pow(abs(sin(v)),2/ny)) >>>     let(z = c*sign(sin(u)) *pow(abs(sin(u)),2/nz)) >>>     [x,y,z] >>> ]; >>> >>> >>> _______________________________________________ >>> 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 > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org