contains

Purpose

Test if a polyhedron/point is contained inside polyhedron.

Syntax

tf = P.contains(S)
tf = P.contains(S, fastbreak)
tf = contains(P, S, fastbreak)
P > S
P >= S
S < P
S <= P

Description

Check if the polyhedron or the point S is contained inside the polyhedron P. The result it the logical statement if ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains1.png and false otherwise. S can be given as polyhedron, it can be a point given as a column (or set of points concatenated column-wise). Notes: Remember that testing the set membership is numerically sensitive and depends on the settings of the absolute and relative tolerances.

Input Arguments

P

polyhedron or an array of polyhedra with m elements

Class: Polyhedron

S

Polyhedron or a polyhedron array or a set of points. Multiple points must be concatenated in a matrix column-wise, where the number of rows corresponds to the dimension of P and the number of columns gives the number of points to test. No automatic transposition is performed!

Class: Polyhedron or double

fastbreak

A logical flag. If true it indicates that the set membership test should be terminated as soon as at least one element of P contains the point S.

Class: logical

Allowed values:

  • 0
  • 1

Default: 0

Output Arguments

tf

True if ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains5.png and false otherwise.
  • If S is a single point or a single polyhedron: status is a ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains6.png vector of true/false, status(i)=true iff P(i) contains S.
  • If S is a matrix of points (i.e., S = [s_1, ..., s_n]) status is a ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains7.png matrix of true/false, status(i, j)=true iff P(i) contains point S(:, j).
  • If S is a polyhedron, then P.contains(x) iff ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains8.png

Class: logical

Allowed values:

  • true
  • false

Example(s)

Example 1

Create two polytopes:
P = ExamplePoly.poly3d_sin('d',3);

S = ExamplePoly.poly3d_sin('d',3); S = S.affineMap(eye(3)*2);
Compare polytopes:
P.contains(S)
ans =

     0

S.contains(P)
ans =

     1

Plot the result
plot([P,S],'alpha',0.3);

../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains_img_1.png

Example 2

Create two polyhedra:
P = ExamplePoly.randHrep;

S = P + ExamplePoly.randVrep('n',1,'nr',1);
Compare polytopes:
P.contains(S)
ans =

     0

S.contains(P)
ans =

     0

Plot the result
plot([S P]);

../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains_img_2.png

Example 3

Create random polyhedron.
 P = ExamplePoly.randVrep; 
 Grid the polyhedron with 5 point over dimension.
 x =  P.grid(5); 
 Test whether each grid point is contained in the polyhedron P. 
 P.contains(x') 
ans =

     1     1     1     1     1     1     1     1

See Also

interiorpoint, le, lt, ge, gt


© 2010-2013 Colin Neil Jones: EPF Lausanne, colin.jones@epfl.ch

© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk

© 2010-2013 Martin Herceg: ETH Zurich, herceg@control.ee.ethz.ch