Generate stl file for random spheres

13 ビュー (過去 30 日間)
SS
SS 2015 年 10 月 1 日
コメント済み: SS 2016 年 2 月 12 日
Hello,
I had a look at the example in matlab documentation for generating a sphere and to export it in stl format http://nl.mathworks.com/help/symbolic/mupad_ref/export-stl.html
What is not clear to me is how do I specify radius and centre of the spheres, so that I could loop through to generate a number of random spheres and generate an stl file?
Thanks a lot.

採用された回答

Rohit Kudva
Rohit Kudva 2015 年 10 月 22 日
Hi SS
The equations for a sphere centered at (m,n,p) with radius 'r' in spherical coordinate system will be
x = m + r*cos(theta)*sin(phi)
y = n+ r*sin(theta)*sin(phi)
z = p+ r*cos(phi)
Thus the code for MuPAD will look like
x:= m+r*cos(u)*sin(v):
y:= n+r*sin(u)*sin(v):
z:= p+r*cos(v):
filename:= NOTEBOOKPATH."sphere.stl":
export::stl(filename, [x, y, z], u = 0 .. 2*PI, v = 0 .. PI, Text)
plot(plot::SurfaceSTL(filename, MeshVisible))
Regards,
Rohit
  1 件のコメント
SS
SS 2016 年 2 月 12 日
Dear Rohit,
Thanks a lot. I waited for 3 weeks and gave up. Just by chance I saw your response now. It works perfectly.
I am now struggling to generate multiple spheres in a single stl file, because m, n, p and r are not accepting vectorial entries.
Moreover, my interest is to develop at least about 10,000 random spheres for which I already have coordinates and radii. Is this possible in a reasonable amount of time in mupad or should I have to use some other method.
Could you please help me with these questions?
Thank you for your time, Regards, SS

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by