3D parametric plot with Open SCAD

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

3D parametric plot with Open SCAD

Aleandro
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: 3D parametric plot with Open SCAD

MichaelAtOz
Administrator
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything,
or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

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!
Reply | Threaded
Open this post in threaded view
|

Re: 3D parametric plot with Open SCAD

atnbueno
In reply to this post by Aleandro

2018-03-29 15:40 GMT+02:00 Aleandro <[hidden email]>:
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



--
Saludos,
Antonio



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: 3D parametric plot with Open SCAD

Aleandro
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: 3D parametric plot with Open SCAD

NateTG
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 the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: 3D parametric plot with Open SCAD

atnbueno
In reply to this post by Aleandro
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 <[hidden email]>:
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



--
Saludos,
Antonio



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: 3D parametric plot with Open SCAD

Aleandro
In reply to this post by NateTG
This works fine and compiles with no errors, than you.  



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org