contains

Purpose

Test if a point is contained inside the union of convex sets.

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 sets in the union U. The result it a logical statement if ../../../../../../fig/mpt/modules/geometry/unions/@Union/contains1.png and false otherwise. If the point is contained inside the union, indices of sets 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/@Union/contains2.png is returned. All sets in the union must have the same dimension, otherwise the evaluation cannot be done.

Input Arguments

U

Single union object that holds sets derived from the ConvexSet class. If Uis an array, use U.forEach().

Class: Union

x

A point in the same dimension as all the sets in the union.

Class: double

fastbreak

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

Class: logical

Allowed values:

  • true
  • false

Default: false

Output Arguments

isin

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

Class: logical

Allowed values:

  • true
  • false

inwhich

Indices of sets that contain ../../../../../../fig/mpt/modules/geometry/unions/@Union/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 two yalmip polytopic sets in 2D.
 x = sdpvar(2,1); 

Y(1) = YSet(x,[randn(8,2)*x<=ones(8,1)]);

Y(2) = YSet(x,[randn(8,2)*x<=ones(8,1)]);
 Create an union of the sets 
 U = Union(Y); 
Check if the point ../../../../../../fig/mpt/modules/geometry/unions/@Union/contains5.png is contained in the union.
 x = [1; 0]; 

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

     1


inwhich =

     1     2


closest =

     []

See Also

feval


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

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