contains

Purpose

Test if a point is contained inside the union of polyhedra in the same dimension.

Syntax

[isin, inwhich, closest] = contains(U, x, fastbreak)
[isin, inwhich, closest] = U.contains(x)
[isin, inwhich, closest] = U.contains(x, fastbreak)

Description

Check if the point x is contained in any of the polyhedra stored in the union U. The result it the logical statement if ../../../../../../fig/mpt/modules/geometry/unions/@PolyUnion/contains1.png and false otherwise. If the point is contained inside the union, indices of the corresponding polyhedra in which the point lie are returned. If the point does not lie in the union, the index of the region with the least distance to the point ../../../../../../fig/mpt/modules/geometry/unions/@PolyUnion/contains2.png is returned.

Input Arguments

U

Single PolyUnion object that holds sets polyhedra in the same dimension.

Class: PolyUnion

x

A point in the same dimension as the union.

Class: double

fastbreak

Do a quick stop in the consecutive search when x is contained in the first polyhedron it founds.

Class: logical

Allowed values:

  • true
  • false

Default: false

Output Arguments

isin

True if ../../../../../../fig/mpt/modules/geometry/unions/@PolyUnion/contains3.png and false otherwise.

Class: logical

Allowed values:

  • true
  • false

inwhich

Indices of sets that contain ../../../../../../fig/mpt/modules/geometry/unions/@PolyUnion/contains4.png. If the fastbreak option is turned on, a single index is returned.

Class: double

closest

If the point is not contained inside the union, this output indicates the index of the set that is the closest to the point x. Note: since this computation is expensive, do not ask for the third output unless you really need it.

Class: double

Example(s)

Example 1

Create five polyhedra in 3D.
for i=1:5, P(i) = ExamplePoly.randVrep('d',3)+rand(3,1); end 
 Create an union of these sets without specifying any properties.
 U = PolyUnion(P); 
Check if the point ../../../../../../fig/mpt/modules/geometry/unions/@PolyUnion/contains5.png is contained in the union.
 x = [1; -1; 0]; 

[isin, inwhich, closest] = U.contains(x) 
isin =

     0


inwhich =

   Empty matrix: 1-by-0


closest =

     5

See Also

feval


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

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