Algorithm Search⌘K

Modeladvanced

Cardinal direction calculus

Also called cardinal direction relations.

Qualitative relations such as north and southwest between points or regions, defined by projections on the axes or by the 3x3 grid around the bounding box of the reference object.

The cardinal direction calculus describes where one object lies with respect to another in terms of the compass: north, northeast, east and so on. For points it is the product of two copies of the point algebra, one per axis, with nine base relations (Frank 1991, Ligozat 1998). For extended regions, the plane is cut into nine tiles by the bounding box of the reference region, and the relation is the set of tiles that the other region occupies (Goyal and Egenhofer, Skiadopoulos and Koubarakis). It is used in geographic information systems and in spatial queries such as "find the lakes north of the city".

The machine

Points. Let a=(xa,ya)a = (x_a, y_a) and b=(xb,yb)b = (x_b, y_b) be points of R2\mathbb{R}^2. The base relation of aa to bb is the pair of point relations (xa?xb,  ya?yb)(x_a \mathrel{?} x_b, \; y_a \mathrel{?} y_b) with each ?∈{<,=,>}? \in \{<, =, >\}, so there are 3×3=93 \times 3 = 9 base relations:

xa<xbx_a < x_b xa=xbx_a = x_b xa>xbx_a > x_b
ya>yby_a > y_b NW N NE
ya=yby_a = y_b W Eq E
ya<yby_a < y_b SW S SE

These are the projection-based directions of Frank (1991). The nine relations are jointly exhaustive and pairwise disjoint, and a relation is a set of them, so there are 29=5122^9 = 512 relations. The converse swaps N and S, E and W, and so on. Composition of base relations works axis by axis: if a(r1,r2)ba \mathrel{(r_1, r_2)} b and b(s1,s2)cb \mathrel{(s_1, s_2)} c, then aa and cc satisfy (r1⋄s1)×(r2⋄s2)(r_1 \diamond s_1) \times (r_2 \diamond s_2), with ⋄\diamond the point algebra composition. For example, N composed with E is NE, and NE composed with SW is the set of all nine relations.

Frank also gave a cone-based version, in which the plane around bb is cut into four or eight cones of equal angle. It is closer to how people use the words, but it is not a product of axis relations.

Regions. Let bb be a bounded region with bounding box [x1,x2]×[y1,y2][x_1, x_2] \times [y_1, y_2]. The four lines x=x1x = x_1, x=x2x = x_2, y=y1y = y_1 and y=y2y = y_2 cut the plane into nine tiles, named B (the box itself), N, NE, E, SE, S, SW, W and NW. The relation of a region aa to bb is the set of tiles in which aa has a part of positive area, written for example N:NEN{:}NE when aa lies above the box and reaches past its right side. Goyal and Egenhofer write this set as a 3×33 \times 3 matrix of bits, the direction-relation matrix.

Any non-empty set of tiles can be the relation of a region that may have several pieces, so there are 29−1=5112^9 - 1 = 511 basic relations. For connected regions without holes, the set of tiles must be connected through shared tile edges, and Skiadopoulos and Koubarakis (2004) count 218 basic relations. A direct count agrees: of the 511 non-empty subsets of the 3×33 \times 3 grid, exactly 218 are connected through shared edges.

What it counts

An input is a qualitative constraint network on nn objects with direction relations as labels. The questions are consistency, a solution, and the minimal labels. Cost is counted in nn.

Points. A network of base relations is consistent if and only if each of its two axis networks is consistent, since the axes are independent. Each axis network is a network of the point algebra, so the check takes O(n2)O(n^2) time for a complete network, for example by merging the points that must be equal and testing the order for a cycle.

Example. The points aNEba \mathrel{NE} b, bNEcb \mathrel{NE} c, cNEac \mathrel{NE} a are inconsistent, since the xx axis needs xa>xb>xc>xax_a > x_b > x_c > x_a. The network aNba \mathrel{N} b, bEcb \mathrel{E} c, aNEca \mathrel{NE} c is consistent: a=(1,1)a = (1, 1), b=(1,0)b = (1, 0), c=(0,0)c = (0, 0).

Regions. Computing the relation of two polygons takes time linear in their sizes: one pass over bb finds its bounding box, and clipping aa against the four lines finds the tiles with positive area. The relations between regions are not closed under converse: from aNba \mathrel{N} b the relation of bb to aa can be S, S:SW, S:SE and others, depending on the widths, so the converse of a basic relation is in general a disjunction.

Relation to other models

  • Point algebra. Each axis of the point calculus is the point algebra, and the point calculus is their product.
  • Rectangle algebra. The rectangle algebra applies the same product idea to intervals, with Allen's 13 relations on each axis. The region relation of aa to bb depends only on aa and the bounding box of bb, so it is coarser than the rectangle relation of the two boxes in some cases and finer in others.
  • Topology. RCC8 says whether regions touch or overlap and has no notion of direction; combinations of RCC8 and cardinal directions have been studied for this reason.
  • Relative orientation. Cardinal directions use a fixed frame. The double-cross calculus and other relative calculi describe a point with respect to the direction defined by two other points.

Known results in the model

problem result source
points, base relations polynomial, axis by axis Ligozat 1998
points, preconvex relations algebraic closure decides; maximal tractable Ligozat 1998
points, all 512 relations NP-complete Ligozat 1998
regions, composition of basic relations computed; the result can be a relation that is not basic Skiadopoulos and Koubarakis 2004
regions, basic constraints, regions may be disconnected O(n5)O(n^5) Skiadopoulos and Koubarakis 2005
regions, disjunctive constraints NP-complete Skiadopoulos and Koubarakis 2005

Preconvexity. As for the interval algebra, a point relation is convex if it is an interval in the lattice of base relations ordered axis by axis, and preconvex if it becomes convex when relations of lower dimension, those with an == on some axis, are added. For networks of preconvex relations, algebraic closure decides consistency (Ligozat 1998).

Composition for regions. Skiadopoulos and Koubarakis (2004) give an algorithm for the composition of two basic region relations. The result is in general a disjunction of basic relations, and because a region relation uses only the bounding box of the reference region, the composition must be computed with care: the box of bb does not fix where the parts of bb lie inside it.

References

  1. Andrew U. Frank, Qualitative spatial reasoning with cardinal directions, 7th Austrian Conference on Artificial Intelligence, Informatik-Fachberichte 287, Springer, 1991, pages 157 to 167 (cone-based and projection-based cardinal directions between points, and their composition)
  2. Gérard Ligozat, Reasoning about cardinal directions, Journal of Visual Languages and Computing 9(1), 1998, pages 23 to 44 (the nine base relations between points, the 512 relations, and the preconvex relations as a maximal tractable subset)
  3. Spiros Skiadopoulos and Manolis Koubarakis, Composing cardinal direction relations, Artificial Intelligence 152(2), 2004, pages 143 to 171 (the relations between extended regions, the 218 basic relations for connected regions, and their composition)
  4. Spiros Skiadopoulos and Manolis Koubarakis, On the consistency of cardinal direction constraints, Artificial Intelligence 163(1), 2005, pages 91 to 135 (an O(n^5) consistency check for basic constraints, and NP-completeness for disjunctive ones)
  5. Roop K. Goyal and Max J. Egenhofer, Similarity of cardinal directions, SSTD 2001, Lecture Notes in Computer Science 2121, Springer, 2001, the direction-relation matrix of a target region with respect to the bounding box of a reference region

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/SKAWD9/text.yaml