Generating random points within a solid from 3D CAD model.

8 Ansichten (letzte 30 Tage)
Jeongho Sohn
Jeongho Sohn am 1 Aug. 2015
Kommentiert: Roger Stafford am 1 Aug. 2015
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.

Antworten (1)

Roger Stafford
Roger Stafford am 1 Aug. 2015
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 Kommentare
Jeongho Sohn
Jeongho Sohn am 1 Aug. 2015
Thanks,
you solved it by approaching parametric math.
But I want rather general method.
Say, the vase cannot be expressed in simple parametric equation (irregular shape), then how can you make a set of points ?
Roger Stafford
Roger Stafford am 1 Aug. 2015
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Model Import finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by