arXiv:1705.03950v2 [cs.DS] 24 May 2017

Zig-zagging in a Triangulation
Wouter Kuijper

Victor Ermolaev

Harm Berntsen

May 25, 2017

1

Introduction

We present an oblivious walk for point-location in 2-dimensional triangulations
and a corresponding, strictly monotonically decreasing distance measure.

2

Problem Description
2

Let T = (V, F, E) be a 2-dimensional triangular tiling of R in quad-edge representation [2], consisting of a set of vertices V , a set of faces F and a set of
2
half-edges E. We say T is locally finite iff for any circle in R it holds that
the set consisting of all edges (vertices, faces) in T that intersect the circle
(circumference or interior) is finite.
Let e ∈ E be some half-edge of this mesh starting at vertex e1 and ending
at vertex e2 . With inv(e) we denote the twin of e such that inv(e)1 = e2 and
inv(e)2 = e1 . With face(e) we denote the face f ∈ F that is, by convention, to
the left of the half-edge e. With next(e) we denote the next half-edge (in the
face winding order) that is also a side of face(e), i.e.: face(next(e)) = face(e).
With prev(e) we denote the previous half-edge (in the face winding order) that
is also a side of face(e), i.e.: face(prev(e)) = face(e). Because we are dealing
with a triangular mesh, in particular, it holds: next(next(e)) = prev(e) and vice
versa.
The problem of point-location [1] that we consider in this note can be for2
mulated as follows: Given a point p ∈ R and an initial half-edge einit ∈ E find
some half-edge egoal ∈ E, using only next(⋅), prev(⋅) and inv(⋅) operations, such
that p ∈ face(egoal ), i.e.: the point is on the face. We, additionally, require the
algorithm to be oblivious, meaning that the next chosen half-edge only depends
on the last-visited half-edge and the goal location.

3

Example of a Zig-Zagging Walk

A walk in a triangulation is a sequence of faces. We concern ourselves here only
with directed walks, such walks attempt to close the distance between some
starting edge (or its corresponding face) and a target point. Directed walks are
1

◦

◦
p
◦

fl

◦

fr

f
◦
e1

e

◦
e2

Figure 1: An example of a zig-zagging motion exhibited during a walk.
important in practice as they are frequently used to navigate meshes as efficient,
flexible space-partitioning data-structures.
One possible application of a directed walk would be to translate mouseclicks to selected faces in a CAD-application. Because such type of interaction
exhibits a lot of locality —i.e.: clicks often happen in close proximity to each
other— it is much more efficient to walk to the corresponding face from the
last-visited one then to perform a, potentially exhaustive, sweep of the entire
mesh, which, in representative cases, may measure in the order of millions or
even billions of faces.
Before we turn to the exposition of the zig-zagging walk, its corresponding
distance measure and termination proof, let us first investigate briefly why a zigzagging motion is a useful and intuitive analogy in thinking about point-location
in two dimensional triangulations.
Since an oblivious walk “forgets” its original point of departure as well as
the route followed to get to the current face, it suffices to consider only the
current half-edge and the corresponding current face (which, by our convention,
is always to the left of the current half-edge) when thinking about the pointlocation problem.
As an example consider Figure 1. Assume that at some point during the walk
we arrive at half-edge e and corresponding face f = face(e). The target point p
is “straight ahead” in the direction of the tip of f . However, going straight is not
an option, because the only faces that are directly linked to f (in the quad-edge
representation) are fl = face(inv(prev(e))) and fr = face(inv(next(e))). Since
“turning back” is not an option either, any route to the target point p will have
to go either over the left or over the right, hence, any route will make a “zig-zag”
motion to reach the target.

2

p2
◦

p3
◦

p1
◦

d1

d2
α2

d3

α1

◦
e1

α3
◦
e2

◦
ep

Figure 2: Examples of point–half-edge distance for various locations of a point.
The previous example may seem particularly inefficient in terms of Euclidian
distance traveled, however note that the complexity of the walk does not, in any
way, depend on the Euclidian distance, rather it depends on the link distance
which, in our case, could be defined as the number of atomic quad-edge relations
(next, prev and inv) that had to be traversed.
One problem that we quickly run into when developing a walking-algorithm
is the fact that Euclidian distance is not a sufficient measure to prove termination: steps do not always strictly decrease the Euclidian distance to the target.
Therefore, to obtain a clear proof of termination, we need an alternative distance measure that takes into account the fact that a step in the walk can make
progress not only in terms of Euclidian distance to the target but also in terms
of orientation towards the target.

4

Distance Measure

For some half-edge e and point p such that e does not intersect p we define the
oriented distance of e to p denoted e ⊾ p as a pair [d, α] where d is defined to
be the Euclidian distance of point p to the closest point ep on the (finite!) line
segment e1 ; e2 corresponding to half-edge e and α is defined to be the (smallest)
angle between e1 ; e2 and the ray p; ep or zero in case p = ep . Since the shortest
ray from p to e ends at either e1 , e2 or the orthogonal projection of p on e1 ; e2
it follows α ≥ π/2. For some examples of how this oriented distance measure is
defined under various relative configurations of the current edge and the target
point, see Figure 2.
We now define a strict partial ordering < on oriented distances such that
′

′

′

′

′

[d, α] < [d , α ] iff d < d ∨ (d = d ∧ α < α )
In order to see how this distance measure allows us to compare various candidate
successor edges consider the example in Figure 3. Here we show a classification
of the points in the space that is to the left of the line supporting the current
2
half-edge e (but not on the current face). So let p ∈ R be the target point
and let l = inv(next(e)) and r = inv(prev(e)) be the two possible successor half3

IV
IIIl

IIl

IIIr

IIr

◦
l2 = r1
l

r

Il

Ir
◦
l1 = e 1

e

◦
e2 = r2

Figure 3: The various areas where the target point may reside.
edges, now let [dl , αl ] = l ⊾ p and [dr , αr ] = r ⊾ p, we classify the space where
the target point p may reside as follows:
• dl < dr and the point of l closest to p is l1 (Il )
• dl < dr and the point of l closest to p is strictly in-between l1 and l2 (IIl )
• dl = dr and αl < αr (IIIl )
• dl = dr and αl = αr (IV)
• dl > dr and αl > αr (IIIr )
• dl > dr and the point of r closest to p is strictly in-between r1 and r2 (IIr )
• dl > dr and the point of r closest to p is r2 (Ir )
Note that area Il or Ir becomes a line in case the triangle is right in its left or
right base angle respectively and empty in case the corresponding angle becomes
obtuse. All the other areas remain non-empty no matter how obtuse or how
thin the triangle becomes.

5

Oriented Distance Walk

We are now in a position to describe the algorithm properly. Let e ∈ E be some
2
initial half-edge, and let p ∈ R be the goal location. The algorithm then goes
as follows:

4

◦

l

◦

r

e

◦

Figure 4: Lemma 5.1, step 1: p lies somewhere in the gray cone
1
2
3
4

if p is to the right–of e then e ← inv(e)
while p ∉ face(e)
l, r ← inv(next(e)), inv(prev(e))
if (l ⊾ p) < (r ⊾ p) then e ← l else e ← r
In line 1 we bootstrap the algorithm by ensuring the invariant that p is
always to the left of e. In line 2 we check the termination condition that p is on
the current face (i.e.: the face to the left of the current half-edge). In line 3 we
compute the two possible successor edges. In line 4 we pick the successor edge
that has the smallest oriented distance to the target point.
Note that, in this algorithm, ties are broken by defaulting to the rightsuccessor edge. Clearly, it is possible to have a leftmost version by defaulting to
the left instead, or a non-deterministic version by allowing either the left or the
right-successor edge whenever l ⊾ p is not strictly less or greater-than r ⊾ p. For
the remainder we will assume the non-deterministic version of the algorithm,
all the results that follow will then hold also for (both) deterministic versions,
as a corollary.
We shall first prove a number of properties of the walk which consequently
will allow us to prove the main result, i.e.: guaranteed termination of the zigzagging walk. First we show that the point will, as an invariant, always be to
the left of the current half-edge.
Lemma 5.1 (Target in Half-space). At every iteration of the walk it holds that
p lies in the half-space to the left of e.
Proof. By induction on the number of iterations. The basis is ensured as a
postcondition of line 1. For the inductive step assume, w.l.o.g., that the left
successor edge l is chosen in line 4, which implies, in the non-deterministic
version, l ⊾ p ≤ r ⊾ p. Now, for contradiction, assume that p lies strictly to
the right of l. By inductive hypothesis we have that p is to the left of e which
places it in the cone formed by l and e (cf. Figure 4). In addition we have the
5

◦

l

r

e

◦

◦

Figure 5: Lemma 5.1, step 2: p lies somewhere in the gray, truncated cone

◦
∠lr

l

r

e

◦

◦

Figure 6: Lemma 5.1, step 3: p lies somewhere in the gray cone

◦

l

◦

r

e

◦

Figure 7: Lemma 5.2, step 1: p lies somewhere in the gray zone

6

◦

l

r

e

◦

◦

Figure 8: Lemma 5.2, step 2a: p lies somewhere in the gray zone

◦

l

∠el
◦

r

e

◦

Figure 9: Lemma 5.2, step 2b: p lies somewhere in the gray cone

7

loop invariant p ∉ face(e) which places p further inside the now truncated cone
formed by l, e and r (cf. Figure 5). Now let [dl , αl ] = l ⊾ p and [dr , αr ] = r ⊾ p,
and note that a ray cast from any point in the truncated cone to l must pass
through r hence we obtain: dl ≥ dr . Now, by assumption, l ⊾ p ≤ r ⊾ p which
implies dl ≤ dr . From the latter two facts it follows that dl = dr and αl ≤ αr
which places p still further inside the cone formed by l and the line orthogonal
to r starting at the tip vertex (cf. Figure 6). However, we see from the diagram
that this implies αl = αr + ∠lr which directly contradicts our assumption that
αl ≤ αr .
Lemma 5.2 (Monotonicity). With every step of the zig-zagging walk the oriented distance of the current edge to the target strictly decreases.
Proof. Assume for contradiction that the oriented distance does not strictly
decrease, i.e.: (e ⊾ p) ≤ (l ⊾ p) and (e ⊾ p) ≤ (r ⊾ p). First note that by
Lemma 5.1 we have that p is to the left of e, and by the loop invariant we have
that p is outside of the current face (cf. Figure 7). Now let ep be the point
on e closest to p. We make a case distinction. As a first case consider ep ≠ e1
and ep ≠ e2 , i.e.: ep is properly contained between e1 and e2 . In this case the
projection of p on e must have been orthogonal (cf. Figure 8). However this
means that the ray from p to e must have passed through one of the two sides
r or l and through the interior of the face which contradicts our assumption
that (e ⊾ p) ≤ (l ⊾ p) and (e ⊾ p) ≤ (r ⊾ p). For the second case consider
ep = e1 or ep = e2 . So, w.l.o.g, assume ep = e1 . Now let [dl , αl ] = l ⊾ p and
[de , αe ] = e ⊾ p. Since e1 = l1 is a shared point with l it must hold dl ≤ de ,
and hence, by assumption that (e ⊾ p) ≤ (l ⊾ p), it must follow that dl = el
and αe ≤ αl , this places p in the cone between e and the line orthogonal to
l emanating from e1 (cf. Figure 9). However, we see from the diagram that
this implies αe = αl + ∠le, which directly contradicts our assumption that
αe ≤ αl .
We are now in position to formulate and prove finite time termination theorem. For this we need local finiteness of T to rule out the possibility of asymptotic walks in dense tessellations.
Theorem 5.3. If T is locally finite, the zig-zagging walk always terminates.
2

Proof. Let p ∈ R be the target point and e ∈ E the initial half-edge, let
′
′
′
′
[d, α] = e ⊾ p, and let E = {e ∈ E ∣ (e ⊾ p) ≤ (e ⊾ p)}. We say E is the
′
neighborhood of e and p. Note that all edges in the neighborhood E intersect
′
a disc centered at p with radius d, hence, by local finiteness of T , it follows E
is a finite set. Now by Lemma 5.2 we have that the zig-zagging walk visits a
′
sequence of half-edges in E that exhibits a strictly monotonically decreasing
′
chain of oriented distances, and, since E is finite, this implies termination.
If we define the local size of the mesh as the size of the neighborhood as
defined in the proof, we actually get the stronger result that the zig-zagging
walk always terminates in a number of steps that is bounded by the local size
of the mesh.
8

◦

◦

◦
◦
Figure 10: A example of a reorienting step in two dimensions.

◦

◦
◦
◦

Figure 11: An example of an approaching step in two dimensions.

5.1

Spiraling in a Tetrahedralization

One of the obvious next questions to consider is whether this result can be
generalized from two to three dimensions. Although we defer formal treatment
to future work, we already give some intuition and a proof sketch as to how this
might be done.
First observe that, in two dimensions, we can define the “current neighborhood circle” to be the smallest circle surrounding the target point that intersects
the current half-edge. A zig-zagging walk then consists of steps that change the
angle of the current half-edge to make it more tangent to the current neighborhood circle (cf. Figure 10) eventually followed by steps that approach the target
and thereby shrink the radius of the current neighborhood circle (cf. Figure 11).
In three dimensions the analogon to the neighborhood circle would be the
smallest sphere surrounding the target point that intersects the face. A spiraling

9

◦

◦

◦

◦
◦
Figure 12: A example of a reorienting step in three dimensions.

◦

◦

◦

◦
◦
Figure 13: An example of an approaching step in three dimensions.
walk through a tetrahedralization would then consist, analogously, of steps that
change the orientation of the current face to make it more tangent to the current
neighborhood sphere (cf. Figure 12) eventually followed by steps that approach
the target and thereby shrink the radius of the current neighborhood sphere (cf.
Figure 13).
In the two dimensional case a single angle was sufficient to characterize
the orientation of the current half-edge w.r.t. the target point. In the three
dimensional case we need at least 2 angles to characterize the orientation of the
current face w.r.t. the target point.
In particular we define the ray as the shortest line segment from the target
point to the closest point on the face, we must then fix a roll roll axis as a
line-segment that lies in the face and intersects the ray.
Given such a roll axis we then define the pitch axis as the line that is orthogonal to both the ray as well as the roll axis. We further define the pitch
10

angle of the face as the angle between the ray and the roll axis and we define
the roll angle as the angle between the face and the plane defined by the pitch
and roll axis.
We then define a pitch minimizing roll axis to be any roll axis that minimizes
the pitch angle, and we define a minimizing roll axis to be any pitch minimizing
roll axis that minimizes the roll angle, i.e.: it minimizes firstly the pitch angle
and secondly the roll angle. We refer to the latter as the minimal pitch angle
and the minimal roll angle.
For some face f and some point p where f does not contain p, we can now
define the oriented distance of f to p, notation: f ⊾ p, as the triple [d, α, β]
where d is the Euclidian distance of the target point to the closest point on the
face, α is the minimal pitch angle and β is the minimal roll angle. We then
define a strict partial order as follows:
′

′

′

′

′

′

′

′

′

[d, α, β] < [d , α , β ] iff d < d ∨ (d = d ∧ α < α ) ∨ (d = d ∧ α = α ∧ β < β )

6

Discussion and Future Work

We defer to future work the formal treatment of the three dimensional case (for
which we already gave some intuitions in the previous section), and, possibly, a
full generalization to n–dimensional simplexes.
Another possible direction that we are interested in is to look for a robust
version of the zig-zagging walk that does not require infinite precision in the
evaluation of the predicates. The hope there is that the clear termination proof
in the infinite precision case can function as a starting point in proving termination in the finite precision case.

References
[1] Olivier Devillers, Sylvain Pion, and Monique Teillaud. Walking in a triangulation. International Journal of Foundations of Computer Science,
13(02):181–199, 2002.
[2] Leonidas Guibas and Jorge Stolfi. Primitives for the manipulation of general
subdivisions and the computation of voronoi. ACM transactions on graphics
(TOG), 4(2):74–123, 1985.

11

