discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

3D parametric plot with Open SCAD

A
Aleandro
Thu, Mar 29, 2018 1:40 PM

Dear all,
I would like to make a three-dimensional parametric plot of the form

x = f(u,v)
y = g(u,v)
z = h(u,v)

as a function of the two parameters u_min < u < u_max, v_min < v < v_max in
Open SCAD. Do you know how to do this?

Note that this is different from plotting a function of two variables, z =
f(x,y), for which there are OpenSCAD libraries available, such as  this one
https://www.thingiverse.com/thing:24897  .

Thank you for your help.
Best,

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

Dear all, I would like to make a three-dimensional parametric plot of the form x = f(u,v) y = g(u,v) z = h(u,v) as a function of the two parameters u_min < u < u_max, v_min < v < v_max in Open SCAD. Do you know how to do this? Note that this is different from plotting a function of two variables, z = f(x,y), for which there are OpenSCAD libraries available, such as this one <https://www.thingiverse.com/thing:24897> . Thank you for your help. Best, -- Sent from: http://forum.openscad.org/
M
MichaelAtOz
Thu, Mar 29, 2018 1:42 PM

Reposting as it didn't make it to the mailing-list.

Aleandro wrote

Dear all,
I would like to make a three-dimensional parametric plot of the form

x = f(u,v)
y = g(u,v)
z = h(u,v)

as a function of the two parameters u_min < u < u_max, v_min < v < v_max
in
Open SCAD. Do you know how to do this?

Note that this is different from plotting a function of two variables, z =
f(x,y), for which there are OpenSCAD libraries available, such as  this
one
<https://www.thingiverse.com/thing:24897>  .

Thank you for your help.
Best,

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


OpenSCAD mailing list

Discuss@.openscad


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

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

Reposting as it didn't make it to the mailing-list. Aleandro wrote > Dear all, > I would like to make a three-dimensional parametric plot of the form > > x = f(u,v) > y = g(u,v) > z = h(u,v) > > as a function of the two parameters u_min < u < u_max, v_min < v < v_max > in > Open SCAD. Do you know how to do this? > > Note that this is different from plotting a function of two variables, z = > f(x,y), for which there are OpenSCAD libraries available, such as this > one > &lt;https://www.thingiverse.com/thing:24897&gt; . > > Thank you for your help. > Best, > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- Sent from: http://forum.openscad.org/
AB
Antonio Bueno
Thu, Mar 29, 2018 3:07 PM

Do you mean something like this?
https://gist.github.com/atnbueno/ef8b30d84c3594f97c75d3a793fcc066

2018-03-29 15:40 GMT+02:00 Aleandro michele.roma@hotmail.it:

Dear all,
I would like to make a three-dimensional parametric plot of the form

x = f(u,v)
y = g(u,v)
z = h(u,v)

as a function of the two parameters u_min < u < u_max, v_min < v < v_max in
Open SCAD. Do you know how to do this?

Note that this is different from plotting a function of two variables, z =
f(x,y), for which there are OpenSCAD libraries available, such as  this one
https://www.thingiverse.com/thing:24897  .

Thank you for your help.
Best,

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


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

--
Saludos,
Antonio

Do you mean something like this? https://gist.github.com/atnbueno/ef8b30d84c3594f97c75d3a793fcc066 2018-03-29 15:40 GMT+02:00 Aleandro <michele.roma@hotmail.it>: > Dear all, > I would like to make a three-dimensional parametric plot of the form > > x = f(u,v) > y = g(u,v) > z = h(u,v) > > as a function of the two parameters u_min < u < u_max, v_min < v < v_max in > Open SCAD. Do you know how to do this? > > Note that this is different from plotting a function of two variables, z = > f(x,y), for which there are OpenSCAD libraries available, such as this one > <https://www.thingiverse.com/thing:24897> . > > Thank you for your help. > Best, > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- Saludos, Antonio
A
Aleandro
Thu, Mar 29, 2018 4:47 PM

This is exactly what I was looking for, thank you. However, the file gives me
a compilation error, see the screenshot attached. Do you know why I get this
error?

Thanks

http://forum.openscad.org/file/t2203/Screen_Shot_2018-03-29_at_6.png

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

This is exactly what I was looking for, thank you. However, the file gives me a compilation error, see the screenshot attached. Do you know why I get this error? Thanks <http://forum.openscad.org/file/t2203/Screen_Shot_2018-03-29_at_6.png> -- Sent from: http://forum.openscad.org/
N
NateTG
Thu, Mar 29, 2018 4:55 PM

I was under the impression you were looking for a parametric patch:
function f(x,y)=cos(x)cos(y);function g(x,y)=cos(x)sin(y);function
h(x,y)=sin(x);xmin=-45; xmax=45; xsteps=12;ymin=-45; ymax=45;
ysteps=12;xstep=(xmax-xmin)/(xsteps);ystep=(ymax-ymin)/(ysteps);points=[
for(j=[0:xsteps])            for(i=[0:ysteps])                [
f(xmin+j
xstep,ymin+i
ystep),
g(xmin+jxstep,ymin+iystep),                  h(xmin+jxstep,ymin+iystep)
]      ];faces=[      for(j=[0:xsteps-1]) for (i=[0:ysteps-1])          [
i      +(ysteps+1) +j*(ysteps+1),            i+1    +(ysteps+1)
+j*(ysteps+1),            i+1                +j*(ysteps+1),            i
+j*(ysteps+1)        ]      ]  ;polyhedron(  points=points,
faces=faces);
This doesn't produce a closed surface.

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

I was under the impression you were looking for a parametric patch: function f(x,y)=cos(x)*cos(y);function g(x,y)=cos(x)*sin(y);function h(x,y)=sin(x);xmin=-45; xmax=45; xsteps=12;ymin=-45; ymax=45; ysteps=12;xstep=(xmax-xmin)/(xsteps);ystep=(ymax-ymin)/(ysteps);points=[ for(j=[0:xsteps]) for(i=[0:ysteps]) [ f(xmin+j*xstep,ymin+i*ystep), g(xmin+j*xstep,ymin+i*ystep), h(xmin+j*xstep,ymin+i*ystep) ] ];faces=[ for(j=[0:xsteps-1]) for (i=[0:ysteps-1]) [ i +(ysteps+1) +j*(ysteps+1), i+1 +(ysteps+1) +j*(ysteps+1), i+1 +j*(ysteps+1), i +j*(ysteps+1) ] ] ;polyhedron( points=points, faces=faces); This doesn't produce a closed surface. -- Sent from: http://forum.openscad.org/
AB
Antonio Bueno
Thu, Mar 29, 2018 5:18 PM

It looks like the problem is the "else" in the list.

I'm using the last snapshot version for Windows (2018.03.10) with all the
experimental features enabled, in particular "lc-else", which allows the
use of "else" in list comprehensions.

If you can't/don't want to use this version or feature, try commenting out
lines 45, 47, 48, 51, 53, and 54:

// faces using those points
lower_triangles = [ for (i = [1:x_steps], j = [1:y_steps])
//if (norm(points[i+(x_steps+1)(j-1)]-points[i-1+(x_steps+1)j]) <
norm(points[i-1+(x_steps+1)
(j-1)]-points[i+(x_steps+1)j]))
[i-1+(x_steps+1)
(j-1), i+(x_steps+1)
(j-1), i-1+(x_steps+1)j]
//else
// [i-1+(x_steps+1)
(j-1), i+(x_steps+1)*(j-1), i+(x_steps+1)j] // middle
edge flipping
];
upper_triangles = [ for (i = [1:x_steps], j = [1:y_steps])
//if (norm(points[i+(x_steps+1)
(j-1)]-points[i-1+(x_steps+1)j]) <
norm(points[i-1+(x_steps+1)
(j-1)]-points[i+(x_steps+1)j]))
[i+(x_steps+1)
(j-1), i+(x_steps+1)*j, i-1+(x_steps+1)j]
//else
// [i-1+(x_steps+1)
(j-1), i+(x_steps+1)*j, i-1+(x_steps+1)*j] // middle
edge flipping
];
triangles = concat(lower_triangles, upper_triangles);
echo(str(len(triangles), " faces"));

That "disables" the "attempt" mentioned at the beginning of the script and
triangulates everything the same.

2018-03-29 18:47 GMT+02:00 Aleandro michele.roma@hotmail.it:

This is exactly what I was looking for, thank you. However, the file gives
me
a compilation error, see the screenshot attached. Do you know why I get
this
error?

Thanks

http://forum.openscad.org/file/t2203/Screen_Shot_2018-03-29_at_6.png

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


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

--
Saludos,
Antonio

It looks like the problem is the "else" in the list. I'm using the last snapshot version for Windows (2018.03.10) with all the experimental features enabled, in particular "lc-else", which allows the use of "else" in list comprehensions. If you can't/don't want to use this version or feature, try commenting out lines 45, 47, 48, 51, 53, and 54: // faces using those points lower_triangles = [ for (i = [1:x_steps], j = [1:y_steps]) //if (norm(points[i+(x_steps+1)*(j-1)]-points[i-1+(x_steps+1)*j]) < norm(points[i-1+(x_steps+1)*(j-1)]-points[i+(x_steps+1)*j])) [i-1+(x_steps+1)*(j-1), i+(x_steps+1)*(j-1), i-1+(x_steps+1)*j] //else // [i-1+(x_steps+1)*(j-1), i+(x_steps+1)*(j-1), i+(x_steps+1)*j] // middle edge flipping ]; upper_triangles = [ for (i = [1:x_steps], j = [1:y_steps]) //if (norm(points[i+(x_steps+1)*(j-1)]-points[i-1+(x_steps+1)*j]) < norm(points[i-1+(x_steps+1)*(j-1)]-points[i+(x_steps+1)*j])) [i+(x_steps+1)*(j-1), i+(x_steps+1)*j, i-1+(x_steps+1)*j] //else // [i-1+(x_steps+1)*(j-1), i+(x_steps+1)*j, i-1+(x_steps+1)*j] // middle edge flipping ]; triangles = concat(lower_triangles, upper_triangles); echo(str(len(triangles), " faces")); That "disables" the "attempt" mentioned at the beginning of the script and triangulates everything the same. 2018-03-29 18:47 GMT+02:00 Aleandro <michele.roma@hotmail.it>: > This is exactly what I was looking for, thank you. However, the file gives > me > a compilation error, see the screenshot attached. Do you know why I get > this > error? > > Thanks > > <http://forum.openscad.org/file/t2203/Screen_Shot_2018-03-29_at_6.png> > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- Saludos, Antonio
A
Aleandro
Thu, Mar 29, 2018 6:00 PM

This works fine and compiles with no errors, than you.

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

This works fine and compiles with no errors, than you. -- Sent from: http://forum.openscad.org/