discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Generate a solid cad model from available math functions

K
Katt
Wed, Jan 10, 2018 3:32 PM

Hi all;

I have two math functions from which I am interested to generate a CAD
model.

Attached is a picture for what I am looking for but not sure how to do it.
http://forum.openscad.org/file/t2047/cad_model.png

The border line equations are given and the shaded black region is the one i
want to generate. Also note that the third dimension does not matter for me
as I am looking at a 2D case. It can be any flexible value.

Thanks!!

--
Sent from: http://forum.openscad.org/

Hi all; I have two math functions from which I am interested to generate a CAD model. Attached is a picture for what I am looking for but not sure how to do it. <http://forum.openscad.org/file/t2047/cad_model.png> The border line equations are given and the shaded black region is the one i want to generate. Also note that the third dimension does not matter for me as I am looking at a 2D case. It can be any flexible value. Thanks!! -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Wed, Jan 10, 2018 3:45 PM

You need to define a polygon
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#polygon
by its vertices. Something like:

verts = [for(i=[0:nverts-1]) [ i/verts, f(i/nverts) ] ];
polygon(verts);

This would be the upper part.

2018-01-10 13:32 GMT-02:00 Katt saideep.pavuluri@pet.hw.ac.uk:

Hi all;

I have two math functions from which I am interested to generate a CAD
model.

Attached is a picture for what I am looking for but not sure how to do it.
http://forum.openscad.org/file/t2047/cad_model.png

The border line equations are given and the shaded black region is the one
i
want to generate. Also note that the third dimension does not matter for me
as I am looking at a 2D case. It can be any flexible value.

Thanks!!

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

You need to define a polygon <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#polygon> by its vertices. Something like: verts = [for(i=[0:nverts-1]) [ i/verts, f(i/nverts) ] ]; polygon(verts); This would be the upper part. 2018-01-10 13:32 GMT-02:00 Katt <saideep.pavuluri@pet.hw.ac.uk>: > Hi all; > > I have two math functions from which I am interested to generate a CAD > model. > > Attached is a picture for what I am looking for but not sure how to do it. > <http://forum.openscad.org/file/t2047/cad_model.png> > > The border line equations are given and the shaded black region is the one > i > want to generate. Also note that the third dimension does not matter for me > as I am looking at a 2D case. It can be any flexible value. > > Thanks!! > > > > > > -- > 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
Wed, Jan 10, 2018 5:00 PM

There was a typo in my previous code.

To get a symetrical shape, given the function f defined in the interval
[0,1]:

nverts = 10;
scalex = 8;
verts = concat(
                [for(i=[0:nverts-1])    [ scalex*i/nverts,  f(i/nverts)

] ],
[for(i=[nverts-1:-1:0]) [ scalex*i/nverts, -f(i/nverts)
] ]
);
polygon(verts);

2018-01-10 13:45 GMT-02:00 Ronaldo Persiano rcmpersiano@gmail.com:

You need to define a polygon
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#polygon
by its vertices. Something like:

verts = [for(i=[0:nverts-1]) [ i/verts, f(i/nverts) ] ];
polygon(verts);

This would be the upper part.

2018-01-10 13:32 GMT-02:00 Katt saideep.pavuluri@pet.hw.ac.uk:

Hi all;

I have two math functions from which I am interested to generate a CAD
model.

Attached is a picture for what I am looking for but not sure how to do it.
http://forum.openscad.org/file/t2047/cad_model.png

The border line equations are given and the shaded black region is the
one i
want to generate. Also note that the third dimension does not matter for
me
as I am looking at a 2D case. It can be any flexible value.

Thanks!!

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

There was a typo in my previous code. To get a symetrical shape, given the function f defined in the interval [0,1]: nverts = 10; scalex = 8; verts = concat( [for(i=[0:nverts-1]) [ scalex*i/nverts, f(i/nverts) ] ], [for(i=[nverts-1:-1:0]) [ scalex*i/nverts, -f(i/nverts) ] ] ); polygon(verts); 2018-01-10 13:45 GMT-02:00 Ronaldo Persiano <rcmpersiano@gmail.com>: > You need to define a polygon > <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#polygon> > by its vertices. Something like: > > verts = [for(i=[0:nverts-1]) [ i/verts, f(i/nverts) ] ]; > polygon(verts); > > > This would be the upper part. > > 2018-01-10 13:32 GMT-02:00 Katt <saideep.pavuluri@pet.hw.ac.uk>: > >> Hi all; >> >> I have two math functions from which I am interested to generate a CAD >> model. >> >> Attached is a picture for what I am looking for but not sure how to do it. >> <http://forum.openscad.org/file/t2047/cad_model.png> >> >> The border line equations are given and the shaded black region is the >> one i >> want to generate. Also note that the third dimension does not matter for >> me >> as I am looking at a 2D case. It can be any flexible value. >> >> Thanks!! >> >> >> >> >> >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > >
TP
Torsten Paul
Wed, Jan 10, 2018 5:39 PM

Just for completeness, in the dev snapshot version concat() is
not needed for this case anymore.

It's enough to simply write:

verts = [
for(i=[0:nverts-1])    [ scalexi/nverts,  f(i/nverts) ],
for(i=[nverts-1:-1:0]) [ scalex
i/nverts, -f(i/nverts) ]
];

ciao,
Torsten.

Just for completeness, in the dev snapshot version concat() is not needed for this case anymore. It's enough to simply write: verts = [ for(i=[0:nverts-1]) [ scalex*i/nverts, f(i/nverts) ], for(i=[nverts-1:-1:0]) [ scalex*i/nverts, -f(i/nverts) ] ]; ciao, Torsten.
C
cbernhardt
Thu, Jan 11, 2018 8:07 PM

Here is some code with a function added for the y coord.
http://forum.openscad.org/file/t1309/poly.jpg

--
Sent from: http://forum.openscad.org/

Here is some code with a function added for the y coord. <http://forum.openscad.org/file/t1309/poly.jpg> -- Sent from: http://forum.openscad.org/