discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Extruding Python functions

GS
Guenther Sohler
Sun, Nov 5, 2023 12:10 PM

Extruding Python functions is a really cool thing!
https://imgpile.com/i/Gwmz6l
[image: image.png]

I am sure we could get many more nice effects using different frequencies
of Lissajous Figures ...

Extruding Python functions is a really cool thing! https://imgpile.com/i/Gwmz6l [image: image.png] I am sure we could get many more nice effects using different frequencies of Lissajous Figures ...
SP
Sanjeev Prabhakar
Sun, Nov 5, 2023 12:39 PM

Great Guenther

On Sun, 5 Nov, 2023, 5:40 pm Guenther Sohler via Discuss, <
discuss@lists.openscad.org> wrote:

Extruding Python functions is a really cool thing!
https://imgpile.com/i/Gwmz6l
[image: image.png]

I am sure we could get many more nice effects using different frequencies
of Lissajous Figures ...


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

Great Guenther On Sun, 5 Nov, 2023, 5:40 pm Guenther Sohler via Discuss, < discuss@lists.openscad.org> wrote: > Extruding Python functions is a really cool thing! > https://imgpile.com/i/Gwmz6l > [image: image.png] > > I am sure we could get many more nice effects using different frequencies > of Lissajous Figures ... > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
J
jon
Sun, Nov 5, 2023 1:10 PM

Can something similar be done just with OpenSCAD, perhaps using a library?

On 11/5/2023 7:39 AM, Sanjeev Prabhakar via Discuss wrote:

Great Guenther

On Sun, 5 Nov, 2023, 5:40 pm Guenther Sohler via Discuss,
discuss@lists.openscad.org wrote:

 Extruding Python functions is a really cool thing!
 https://imgpile.com/i/Gwmz6l
 image.png

 I am sure we could get many more nice effects using different
 frequencies of Lissajous Figures ...
 _______________________________________________
 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

Can something similar be done just with OpenSCAD, perhaps using a library? On 11/5/2023 7:39 AM, Sanjeev Prabhakar via Discuss wrote: > Great Guenther > > > On Sun, 5 Nov, 2023, 5:40 pm Guenther Sohler via Discuss, > <discuss@lists.openscad.org> wrote: > > Extruding Python functions is a really cool thing! > https://imgpile.com/i/Gwmz6l > image.png > > I am sure we could get many more nice effects using different > frequencies of Lissajous Figures ... > _______________________________________________ > 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
GS
Guenther Sohler
Sun, Nov 5, 2023 1:24 PM

Hi John,

I am confident that this is possible with OpenSCAD only. I would guess this
is included in BOSL2, maybe Inphase's closepoints
function can exactly do that as well.
The advantage here is that the functionality is exactly there, where you
expect it(at rotate_extrude).(And you additionally have the option to add
more sophisticated things like more formulas, calculations, or e.g. getting
data from a file)

The callback thing is not yet final, trying to get it more general(like
using same for linear_extrude and path_extrude) and/or get the most
important set of parameters to rotate_extrude
but the main idea is there already i would say

Guenther

On Sun, Nov 5, 2023 at 2:10 PM jon via Discuss discuss@lists.openscad.org
wrote:

Can something similar be done just with OpenSCAD, perhaps using a library?

On 11/5/2023 7:39 AM, Sanjeev Prabhakar via Discuss wrote:

Great Guenther

On Sun, 5 Nov, 2023, 5:40 pm Guenther Sohler via Discuss, <
discuss@lists.openscad.org> wrote:

Extruding Python functions is a really cool thing!
https://imgpile.com/i/Gwmz6l
[image: image.png]

I am sure we could get many more nice effects using different frequencies
of Lissajous Figures ...


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


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


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

Hi John, I am confident that this is possible with OpenSCAD only. I would guess this is included in BOSL2, maybe Inphase's closepoints function can exactly do that as well. The advantage here is that the functionality is exactly there, where you expect it(at rotate_extrude).(And you additionally have the option to add more sophisticated things like more formulas, calculations, or e.g. getting data from a file) The callback thing is not yet final, trying to get it more general(like using same for linear_extrude and path_extrude) and/or get the most important set of parameters to rotate_extrude but the main idea is there already i would say Guenther On Sun, Nov 5, 2023 at 2:10 PM jon via Discuss <discuss@lists.openscad.org> wrote: > Can something similar be done just with OpenSCAD, perhaps using a library? > > > On 11/5/2023 7:39 AM, Sanjeev Prabhakar via Discuss wrote: > > Great Guenther > > > On Sun, 5 Nov, 2023, 5:40 pm Guenther Sohler via Discuss, < > discuss@lists.openscad.org> wrote: > >> Extruding Python functions is a really cool thing! >> https://imgpile.com/i/Gwmz6l >> [image: image.png] >> >> I am sure we could get many more nice effects using different frequencies >> of Lissajous Figures ... >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RD
Revar Desmera
Mon, Nov 6, 2023 2:43 AM

On Nov 5, 2023, at 5:24 AM, Guenther Sohler via Discuss discuss@lists.openscad.org wrote:

I am confident that this is possible with OpenSCAD only. I would guess this is included in BOSL2, maybe Inphase's closepoints
function can exactly do that as well.

Eh, sorta?  BOSL2 doesn't specifically have anything to generate this from a function, but I suspect it'd be trivial to generate a set of vertices to pass to vnf_vertex_array() in a few lines of code.  I'd have to know a few things first, though:

  • Are the ang1 and ang2 arguments to profile() equivalent to theta and phi in cylindrical coordinates, relative to the origin?
  • Is ang2 going from 0 to 180, or from -90 to 90, or is it a full 360 sweep?
  • What does the offset argument to your rotate_extrude() do?
  • Revar
> On Nov 5, 2023, at 5:24 AM, Guenther Sohler via Discuss <discuss@lists.openscad.org> wrote: > > I am confident that this is possible with OpenSCAD only. I would guess this is included in BOSL2, maybe Inphase's closepoints > function can exactly do that as well. Eh, sorta? BOSL2 doesn't specifically have anything to generate this from a function, but I suspect it'd be trivial to generate a set of vertices to pass to `vnf_vertex_array()` in a few lines of code. I'd have to know a few things first, though: * Are the ang1 and ang2 arguments to `profile()` equivalent to theta and phi in cylindrical coordinates, relative to the origin? * Is ang2 going from 0 to 180, or from -90 to 90, or is it a full 360 sweep? * What does the offset argument to your `rotate_extrude()` do? - Revar
RD
Revar Desmera
Mon, Nov 6, 2023 2:55 AM

Nevermind.  I figured it out.

include <BOSL2/std.scad>
liss_fn = function(ang1,ang2) (2+cos(3*ang2)+0.25*cos(3*ang2))*(1+sin(ang1)/2);
module rotate_sweep_by_func(fn,offset) {
    rows = [
        for (ang1=[0:5:360])
        let(
            profile = [
                for (ang2=[0:5:360])
                offset + polar_to_xy(liss_fn(ang1,ang2), ang2)
            ]
        )
        zrot(ang1, p=xrot(90, p=path3d(profile)))
    ];
    vnf = vnf_vertex_array(rows);
    vnf_polyhedron(vnf, convexity=10);
}
rotate_sweep_by_func(liss_fn, offset=[3,0]);

  • Revar

On Nov 5, 2023, at 6:43 PM, Revar Desmera revarbat@gmail.com wrote:

On Nov 5, 2023, at 5:24 AM, Guenther Sohler via Discuss discuss@lists.openscad.org wrote:

I am confident that this is possible with OpenSCAD only. I would guess this is included in BOSL2, maybe Inphase's closepoints
function can exactly do that as well.

Eh, sorta?  BOSL2 doesn't specifically have anything to generate this from a function, but I suspect it'd be trivial to generate a set of vertices to pass to vnf_vertex_array() in a few lines of code.  I'd have to know a few things first, though:

  • Are the ang1 and ang2 arguments to profile() equivalent to theta and phi in cylindrical coordinates, relative to the origin?
  • Is ang2 going from 0 to 180, or from -90 to 90, or is it a full 360 sweep?
  • What does the offset argument to your rotate_extrude() do?
  • Revar
Nevermind. I figured it out. ``` include <BOSL2/std.scad> liss_fn = function(ang1,ang2) (2+cos(3*ang2)+0.25*cos(3*ang2))*(1+sin(ang1)/2); module rotate_sweep_by_func(fn,offset) { rows = [ for (ang1=[0:5:360]) let( profile = [ for (ang2=[0:5:360]) offset + polar_to_xy(liss_fn(ang1,ang2), ang2) ] ) zrot(ang1, p=xrot(90, p=path3d(profile))) ]; vnf = vnf_vertex_array(rows); vnf_polyhedron(vnf, convexity=10); } rotate_sweep_by_func(liss_fn, offset=[3,0]); ```  - Revar > On Nov 5, 2023, at 6:43 PM, Revar Desmera <revarbat@gmail.com> wrote: > > >> On Nov 5, 2023, at 5:24 AM, Guenther Sohler via Discuss <discuss@lists.openscad.org> wrote: >> >> I am confident that this is possible with OpenSCAD only. I would guess this is included in BOSL2, maybe Inphase's closepoints >> function can exactly do that as well. > > Eh, sorta? BOSL2 doesn't specifically have anything to generate this from a function, but I suspect it'd be trivial to generate a set of vertices to pass to `vnf_vertex_array()` in a few lines of code. I'd have to know a few things first, though: > > * Are the ang1 and ang2 arguments to `profile()` equivalent to theta and phi in cylindrical coordinates, relative to the origin? > * Is ang2 going from 0 to 180, or from -90 to 90, or is it a full 360 sweep? > * What does the offset argument to your `rotate_extrude()` do? > > - Revar >