isInside

Purpose

Test if a point is contained inside polyhedron in H-representation.

Syntax

[isin, inwhich, closest] = isInside(Pn, x0, Options)
[isin, inwhich, closest] = Pn.isInside(x0, Options)

Description

Check if the point x0 is contained inside the polyhedron array Pn. The result it the logical statement if ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isinside1.png and false otherwise. P must be given in H-representation, otherwise an error is thrown. Note that this operation depends on the settings of absolute tolerance that can be changed in Options settings.

Input Arguments

P

Polyhedron in H-representation.

Class: Polyhedron

x0

A point in the same dimension as polyhedron and given as real column vector.

Class: double

Options

A structure with the option settings for point location problem.

Class: struct

Options.abs_tol

Absolute tolerance for checking the satisfaction of inequalities and equalities.

Class: double

Default: mptopt.abs_tol

Options.fastbreak

If Pn is the polyhedron array, then do a quick stop in the consecutive search when x0 is contained in any of the polyhedrons.

Class: logical

Allowed values:

  • true
  • false

Default: false

Output Arguments

isin

True if ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isinside2.png and false otherwise.

Class: logical

Allowed values:

  • true
  • false

inwhich

If Pn is an array of polyhedra in the same dimension, than isin indicates which polyhedra from this array contain the point x0.

Class: double

closest

If Pn is an array of polyhedra in the same dimension and none of polyhedra contains x0, then the field closest indicates which polyhedra has the closest distance for x0 to lie in it's interior.

Class: double

Example(s)

Example 1

Create two polytopes in 2D.
P(1) = ExamplePoly.randHrep;

P(2) = ExamplePoly.randHrep+[1;1];
Check if the point x0=[1.1;0.9] is contained in any of them.
 x0 = [1.1; 0.9]; 

[isin, inwhich] = P.isInside(x0)
isin =

     1


inwhich =

     2

Plot the point and polyhedra
plot(P); hold on; text(x0(1),x0(2),'\bf x')

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

See Also

contains


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

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