Generating random points within a solid from 3D CAD model.
7 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to generate 100 random point within the solid vase (attached .gif file) ; NOT inside the hollow region, but the closed volume of the solid only.
How can I do this work on matlab?
Well, I can make the solid file as a set of points on the surface of the vase.
Thanks.
0 个评论
回答(1 个)
Roger Stafford
2015-8-1
Let an x,y,z coordinate system be located with the origin on, and the z-axis along, the central axis of your vase. Let R be a sufficiently large radius and zL and zU be lower and upper bounds of a solid circular cylinder that will completely enclose your vase. Then generate a large number, N, say, N = 10000, of random points that lie within this solid cylinder and from them select 100 that are also within the vase.
Here is how to generate the N points with coordinates (x,y,z) within the solid cylinder:
t = 2*pi*rand(N,1);
r = R*sqrt(rand(N,1));
x = r.*cos(t);
y = r.*sin(t);
z = (zU-zL)*rand(N,1)+zL;
Now select from among these N points, the first 100 of them that lie within the vase. I assume you are able to do this with the parameters defined by your CAD model.
2 个评论
Roger Stafford
2015-8-1
It is absolutely essential that you have a method that either can directly generate a point randomly within your volume or else detect whether or not a random point generated in a simpler enclosing volume does in fact lie within the given volume. There is no way out of doing that, however irregular your volume may be. Such a determination is not necessarily the result of only a single expression but could require many such tests. Somehow the detailed shape of your volume has to enter into the action.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model Import 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!