isNeighbor

Purpose

Test if a polyhedron touches another polyhedron along a given facet.

Syntax

ts = P.isNeighbor(Q)
ts = isNeighbor(P,Q)
[ts, iP, iQ] = isNeighbor(P,Q,fP,fQ)

Description

Return true if the polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor1.png shares with the polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor2.png a part of a common facet. Both polyhedrons must be in H-representation. If they are not, the irredundant H-representation will be computed. The function tests if the intersection of two polyhedra ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor3.png and ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor4.png in dimension ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor5.png is nonempty and is of dimension ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor6.png. If this holds, then the two polyhedra are touching themself along one facet. For closer explanation, see the example below.

Input Arguments

P

Polyhedron in H-representation

Class: Polyhedron

Q

Polyhedron in H-representation

Class: Polyhedron

fP

Index of a facet to test from polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor7.png.

Class: double

fQ

Index of a facet to test from polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor8.png.

Class: double

Output Arguments

ts

Logical statement if the polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor9.png touches ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor10.png along the facet.

Class: logical

Allowed values:

  • true
  • false

iP

Index of a facet from polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor11.png that touches the polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor12.png.

Class: double

iQ

Index of a facet from polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor13.png that touches the polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/isneighbor14.png.

Class: double

Example(s)

Example 1

Create three neighboring polyhedra R1, R2, and R3.
 R1 = Polyhedron([0 0; 2 0; 0 1; 2 1]); 

 R2 = Polyhedron([1 0; 2 0; 1 -1; 2 -1]); 

 R3 = Polyhedron([2 0; 3 0; 2 -1; 3 -1]); 
 Plot the polyhedrons to see that they are touching themself.
 plot([R1 R2 R3], 'showindex', true) 

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

Check that polyhedron R1 touches polyhedron R2.
 R1.isNeighbor(R2) 
ans =

     1

Check that the fourth facet of the polyhedron R2 touches the second facet of polyhedron R3.
 [ts, iR2, iR3] = R2.isNeighbor(R3) 
ts =

     1


iR2 =

     2


iR3 =

     4

Actually, the facets of R2 and R3 are the same, so these polyhedra have face to face property that can be checked using isAdjacent method.
 R2.isAdjacent(R3) 
ans =

     1

See Also

isadjacent


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