Generate random coordinates inside a convex polytope
Mostrar comentarios más antiguos
I am trying to generate a random set of coordinates inside a randomly-shaped (convex) polytope defined by its bounding surfaces. My idea is to generate random trial coordinates in the smallest box containing the domain, and check if the point actually lies inside the polytope after. I am struggling with this last part: how do you check if a point is inside a given polytope?
3 comentarios
My idea is to generate random trial coordinates in the smallest box containing the domain, and check if the point actually lies inside the polytope after.
Is this a 3D polytope? In higher dimensions, the minimum bounding box can be quite a bit larger in volume than the polytope. It can take a huge number of randomizations to hit a point lying in the polytope depending on the dimension of the space.
Alessandro
el 3 de Mzo. de 2017
John D'Errico
el 4 de Mzo. de 2017
No rejection needed. See my answer.
Respuesta aceptada
Más respuestas (2)
A polytope is described by linear in/equalities
A*x<=b
Aeq*x=beq
To see if a point lies in the polytope, test whether it satisfies the inequalities to some tolerance.
You should be able to construct the system of inequalities directly, since you say you already know the bounding surfaces. If, on the other hand, you are starting with the polytope vertices, you can derive the inequalities, for example, using VERT2LCON ( Download ).
2 comentarios
Alessandro
el 3 de Mzo. de 2017
Matt J
el 4 de Mzo. de 2017
Yes, that is the idea. Note, however, that you can test not just one, but many points using vectorized linear algebra operations, i.e.,
isinpolytope = all( bsxfun(@le, A*X,b) ,1)
where X is a 3xN matrix of trial points.
Categorías
Más información sobre Bounding Regions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




