Discrete & Computational Geometry

, Volume 47, Issue 4, pp 691–710 | Cite as

Consistent Digital Line Segments

  • Tobias Christ
  • Dömötör Pálvölgyi
  • Miloš StojakovićEmail author


We introduce a novel and general approach for digitalization of line segments in the plane that satisfies a set of axioms naturally arising from Euclidean axioms. In particular, we show how to derive such a system of digital segments from any total order on the integers. As a consequence, using a well-chosen total order, we manage to define a system of digital segments such that all digital segments are, in Hausdorff metric, optimally close to their corresponding Euclidean segments, thus giving an explicit construction that resolves the main question of Chun et al. (Discrete Comput. Geom. 42(3):359–378, 2009).


Digitalization Plane Integer grid 

1 Introduction

One of the most fundamental challenges in digital geometry is to define a “good” digital representation of a geometric object. Of course, the meaning of the word “good” here heavily depends on particular conditions we may impose. Looking at the problem of digitalization in the plane, the goal is to find a set of points on the integer grid ℤ2 that approximates well a given object. The topology of the grid ℤ2 is commonly defined by the graph whose vertices are all the points of the grid, and each point is connected by an edge to each of the four points that are either horizontally or vertically adjacent to it.

Knowing that a straight line segment is one of the most basic geometric objects and a building block for many other objects, defining its digitalization in a satisfying manner is vital. Hence, it is no wonder that this has been a hot scientific topic in the last few decades, see [4] for a recent survey and [2, 3, 6] for related work, dealing with the problem of representing objects in digital geometry without causing topological and combinatorial inconsistencies.

For any pair of points p and q in the grid ℤ2 we want to define the digital line segment S(p,q) connecting them, that is, {p,q}⊆S(p,q)⊆ℤ2. Chun et al. in [1] put forward the following four axioms that arise naturally from properties of line segments in Euclidean geometry.
  1. (S1)

    Grid path property: For all p,q∈ℤ2, S(p,q) is the vertex set of a path from p to q in the grid graph.

  2. (S2)

    Symmetry property: For all p,q∈ℤ2, we have S(p,q)=S(q,p).

  3. (S3)

    Subsegment property: For all p,q∈ℤ2 and every rS(p,q), we have S(p,r)⊆S(p,q).

  4. (S4)

    Prolongation property: For all p,q∈ℤ2, there exists r∈ℤ2, such that rS(p,q) and S(p,q)⊆S(p,r).

First, note that (S3) is not satisfied by the usual way a computer visualizes a segment. A natural definition of the digital straight segment between p=(p x ,p y ) and q=(q x ,q y ), where p x q x and 0≤q y p y <q x p x , is \(\{(x, \lfloor (x-p_{x})\frac{q_{y}-p_{y}}{q_{x}-p_{x}}+p_{y}+0.5 \rfloor): p_{x}\leq x \leq q_{x} \}\), see [4]. This does not satisfy (S1), but it could be easily fixed by a slight modification of the definition. Still, it also does not satisfy (S3), for example, for p=(0,0),r=(1,0),q=(4,1), the digital subsegment from r to q is not contained in the digital segment from p to q, see Fig. 1.
Fig. 1

Axiom (S3) not satisfied for the usual way a computer visualizes a segment: The subsegment from r to q is not contained in the segment from p to q

Even though the set of axioms (S1)–(S4) seems rather natural, there are still some fairly exotic examples of digital segment systems that satisfy all four of them. For example, let us fix a double spiral \(\mathcal{D}\) centered at an arbitrary point of ℤ2, traversing all the points of ℤ2. As it is a spanning path of the grid graph, we can set S(p,q) to be the path between p and q on \(\mathcal{D}\), for every p,q∈ℤ2. It is easy to verify that this system satisfies axioms (S1)–(S4).

Another condition was introduced in [1] to enforce the monotonicity of the segments, ruling out pathological examples like the one above.
  1. (S5)

    Monotonicity property: If both p,q∈ℤ2 lie on a line that is either horizontal or vertical, then the whole segment S(p,q) belongs to this line.


Here, we have phrased the monotonicity axiom differently, but still, the system of axioms (S1)–(S5) remains equivalent to the one given in [1]. The monotonicity axiom in [1] is given in the following form: “(R5) For any rS(pq), \(|\overline{pr}| \leq|\overline{pq}|\), where \(|\overline{ab}|\) is the length of the Euclidean segment from a to b”. Now (S5) follows immediately from (S1), (S3) and (R5), whereas (S5) together with (S1) and (S3) readily implies (R5).

We call a system of digital line segments that satisfies the system of axioms (S1)–(S5) a consistent digital line segments system (CDS). It is straightforward to verify that every CDS also satisfies the following three conditions.
  1. (C1)

    If the slope of the Euclidean line going through p and q is non-negative, then the slope of the Euclidean line going through any two points of S(p,q) is non-negative. The same holds for non-positive slopes.

  2. (C2)

    For all p,q∈ℤ2, the grid-parallel box spanned by points p and q contains S(p,q).

  3. (C3)

    If the intersection of two digital segments contains two points p,q∈ℤ2, then their intersection also contains the whole digital segment S(p,q).


We give a simple example of a CDS, where the segments follow the boundary of the grid-parallel box spanned by the endpoints. Let p,q∈ℤ2 be two points with coordinates p=(p x ,p y ) and q=(q x ,q y ). If p y q y , we define S(p,q)=S(q,p)={(x,p y ):min{p x ,q x }≤x≤max{p x ,q x }}∪{(q x ,y):p y yq y }}. If p y >q y , we swap the points p and q, and define the segment as in the previous case.

It can be easily verified that this way we defined a CDS, but the digital segments in this system visually still do not resemble well the Euclidean segments.

One of the standard ways to measure how close a digital segment is to a Euclidean segment is to look at their Hausdorff distance. For points v,w∈ℝ2 and A⊆ℝ2, let d(v,w)=|vw| and d(v,A)=inf aA d(v,a) denote the usual Euclidean distances between two points, and between a point and a set. For two sets A and B, we denote their Hausdorff distance by H(A,B), so
$$H(A,B) = \max\Bigl\{ \sup_{a \in A} d(a,B),\, \sup_{b \in B} d(b,A)\Bigr\}.$$
The main question raised in [1] was if it is possible to define a CDS such that a Euclidean segment and its digitalization have a reasonably small Hausdorff distance. More precisely, the goal is to find a CDS satisfying the following condition. Here and throughout the paper log denotes the logarithm of base 2.
  1. (H)

    Small Hausdorff distance property: For every p,q∈ℤ2, we have \(H(\overline{pq},S(p,q))\allowbreak = O(\log d(p,q))\).


Note that in the CDS example we gave, the Hausdorff distance between a Euclidean segment of length d and its digitalization can be as large as d/2.

While this question was not resolved in [1], a clever construction of a system of digital rays emanating from the origin of2 that satisfy (S1)–(S5) and (H) was presented. Moreover, it was shown using Schmidt’s theorem [5] that already for rays emanating from the origin, the log-bound imposed in condition (H) is the best bound we can hope for, directly implying the following theorem.

Theorem 1

(Chun et al. [1])

There exists a constant c>0, such that for any CDS and any >0, there exist p,q∈ℤ2 with d(p,q)>, such that \(H(\overline{pq},S(p,q))> c\log d(p,q)\).

In this paper, we introduce a novel and general approach for the construction of a CDS. Namely, for any total order ≺ on ℤ, we show how to derive a CDS from ≺. (By total order we always mean a strict total order.) This process is described in Sect. 2. As a consequence, in Sect. 3, we manage to define a CDS that satisfies (H), deriving it from a specially chosen order on ℤ, and thus giving an explicit construction that resolves the main question of [1].

Theorem 2

There is a CDS that satisfies condition (H).

Note that Theorem 1 ensures that such a CDS is optimal up to a constant factor in terms of the Hausdorff distance from the Euclidean segments. In Sect. 4 we make a step toward a characterization of CDSes, demonstrating their natural connection to total orders on ℤ, while in Sect. 5 we make use of the digital line segment definition to introduce digital lines. Finally, in Sect. 6 we discuss prospects of using a similar approach to define a CDS in higher dimensions.

2 Digital Line Segments Derived from a Total Order on ℤ

Let ≺ be a total order on ℤ. We are going to define a CDS \(\mathcal{S}_{\prec}\), deriving it from ≺.

Let p,q∈ℤ2, p=(p x ,p y ) and q=(q x ,q y ). If p x >q x , we swap p and q. Hence, from now on we may assume that p x q x .

If p y q y , then S (p,q) is defined as follows. We start at the point p=(p x ,p y ) and we repeatedly go either up or to the right, visiting the points from ℤ2, until we reach q. Note that the sum of the coordinates x+y increases by 1 in each step. In total we have to make q x +q y p x p y steps and in exactly q y p y of them we have to go up. The decision whether to go up or to the right is made as follows: if we are at a point (x,y) for which x+y is among the q y p y greatest elements of the interval [p x +p y ,q x +q y −1] according to ≺, we go up, otherwise we go to the right. We will refer to this interval as the segment interval.

If p y >q y , that is, if p is the top-left and q the bottom-right corner of the grid-parallel box spanned by p and q, then we define S (p,q) as the mirror reflection of S ((−q x ,q y ),(−p x ,p y )) over the y-axis.


Suppose p=(0,0) and q=(2,2). Their segment interval consists of four numbers, 0,1,2,3. If ≺ is the natural order on ℤ, then the two greatest elements of the segment interval are 2 and 3. Since 0+0 is not one of these, at (0,0) we go right, to (1,0). At (1,0) we again go to the right, to (2,0), from there to (2,1) (since 2+0 is one of the greater elements) and finally to (2,2), see Fig. 2. In fact, it can be easily seen that using the natural order on ℤ we get the CDS mentioned in Sect. 1, the one that always follows the boundary of the box spanned by the endpoints.
Fig. 2

Segments obtained from the natural order on ℤ: Going from (0,0) to (2,2)

Theorem 3

\(\mathcal{S}_{\prec}\), defined as above, is a CDS.


We will verify that \(\mathcal{S}_{\prec}\) satisfies the axioms (S1)–(S5).

(S1) The condition (S1) follows directly from the definition of \(\mathcal{S}_{\prec}\).

(S2) Let p,q be two points from ℤ2. If the first coordinates of p and q are different, then condition (S2) follows directly. Otherwise, p and q belong to the same vertical line, and from the construction we see that both S (p,q) and S (q,p) consist of all the points on that line between p and q.

(S3) For a contradiction, assume that there are points p=(p x ,p y ), q=(q x ,q y ) and r=(r x ,r y ), with rS (p,q), such that \(S_{\prec}(p,r) \not\subseteq S_{\prec}(p,q)\). W.l.o.g. we may assume that \(\overline{pq}\) has a non-negative slope.

Case 1. p x q x and p y q y . We also have p x r x and p y r y , and going on each of the segments S (p,r) and S (p,q) point-by-point starting from p, we move either up or right. By assumption, these two segments separate at some point (a,b) and then meet again, for the first time after this separation, at some other point (c,d), see Fig. 3. One of the segments goes up at (a,b) and enters (c,d) horizontally coming from the left, which implies that a+b is among the greater numbers of the segment interval of this segment, while c+d−1 is not, thus c+d−1≺a+b. But the other segment goes horizontally at (a,b) and enters (c,d) vertically coming from below, which similarly implies a+bc+d−1, a contradiction.
Fig. 3

Two paths splitting up at (a,b) and meeting again at (c,d)

Case 2. q x p x and q y p y . We also have q x r x and q y r y . By assumption, the two segments starting at q and r, S (q,p) and S (r,p), separate at some point (a,b) and then meet again, for the first time after this separation, at some other point (c,d). Using the same argument as before, we get a contradiction. Hence, (S3) holds.

(S4) To show that condition (S4) holds, consider the segment from p=(p x ,p y ) to q=(q x ,q y ). W.l.o.g. we can assume that p x q x and p y q y . We distinguish two cases.

Case 1. If q x +q y is among the q y p y +1 greatest numbers of [p x +p y ,q x +q y ] according to ≺, then we can prolong the segment going one step vertically up, that is, the segment S ((p x ,p y ),(q x ,q y +1)) contains the segment S ((p x ,p y ),(q x ,q y )) as a subsegment.

Case 2. If, on the other hand, q x +q y is not among the q y p y greatest numbers of [p x +p y ,q x +q y ], we can prolong the segment horizontally to the right, that is, S ((p x ,p y ),(q x ,q y ))⊂S ((p x ,p y ),(q x +1,q y )).

Note that if q x +q y is exactly the (q y p y +1)th number in [p x +p y ,q x +q y ], then the conclusions of both cases are true, and indeed the rays emanating from (p x ,p y ) split at (q x ,q y ).

(S5) The condition (S5) follows directly from the definition of \(\mathcal{S}_{\prec}\). □

Apparently, for segments with non-negative slope, in the definition of S (p,q), only the sum of the coordinates of the points plays a role, so if we translate p and q by a vector (t,−t), for any integer t, the digital line segment will look the same.

Observation 4

Let t∈ℤ be an integer, and let p and q be two points determining a line with non-negative slope. Then S (p+(t,−t),q+(t,−t))=S (p,q)+(t,−t)={(x+t,yt)∈ℤ2:(x,y)∈S (p,q)}.

It might be desirable to have translation invariance in any direction. But if we insist on that and impose the condition that S (p+(a,b),q+(a,b))=S (p,q)+(a,b) for any vector (a,b)∈Z 2, the problem becomes trivial. It is easy to see that the CDS defined in Sect. 1 following the grid-parallel box, and its counterpart—the CDS we get by always following the box on the other side, are the only solutions that are translation invariant in every direction.

3 Digital Segments with Small Hausdorff Distance to Euclidean Segments

For integers k≠0 and l≥2, let |k| l denote the number of times k is divisible by l, that is,
$$|k|_l = \max\bigl\{m: l^m \,|\, k \bigr\}.$$
We define |0| l to be infinity, that is, |0| l is defined to be greater than |k| l for any k≠0. A total order on ℤ is defined as follows. Let ab if and only if there exists a non-negative integer i such that |ai|2<|bi|2, and for all j∈{0,…,i−1} we have |aj|2=|bj|2. In plain words, for two integers a and b, we say that the one that contains a higher power of 2 is greater under ≺. In case of a tie, we repeatedly subtract 1 from both a and b, until at some point one of them contains a higher power of 2 than the other. Thus, for example, −1≺−5≺3≺−3≺5≺1≺−2≺6≺−6≺2≺−4≺4≺0.

For positive integers, this is equivalent to ordering them based on the least significant difference in the binary representation. Note that if we take the elements of an interval of the form (−2 n ,2 n ) in ≺-decreasing order and we apply the function 0.5−x2n−1 to them, then we get the first few elements of the Van der Corput sequence [7].

We will prove that using this total order to define the system of digital line segments \(\mathcal{S}_{\prec}\), as described in the previous section, we obtain a CDS which satisfies condition (H). In Fig. 4 we give some examples of digital segments in this CDS, and Fig. 5 shows the segments emanating from (0,0) to some neighboring points, as well as the segments from (2,3) to the neighboring points.
Fig. 4

Some digital line segments

Fig. 5

Digital line segments emanating from (0,0) and from (2,3)

At first sight it may be surprising to observe that all the segments emanating from the origin in our construction coincide with the ones given in the construction of digital rays in [1]. However, it is not a coincidence, as the construction from [1], though different in nature, also relies on the same total order on the integers.

Recall that for points v,w∈ℝ2 and A⊆ℝ2, d(v,w)=|vw| and d(v,A)=inf aA d(v,a) denote the usual Euclidean distances between points and between a point and a set, respectively. For p,q,r,s∈ℤ2, by \(\overline {pqrs}\) we denote the union of the Euclidean line segments from p to q, from q to r, and from r to s.

Observation 5

For any p,q∈ℤ2, \(H(S_{\prec}(p,q),\overline{pq}) =\max\{d(r,\overline{pq}) : r \in S_{\prec}(p,q) \}\).

We proceed by proving three statements that we will ultimately use to prove Theorem 2.

Moving from a digital segment to one of its subsegments, the Hausdorff distance to the corresponding Euclidean segment may increase. But the following lemma shows that the distance can at most double.

Lemma 6

If p,q∈ℤ2 and r,sS (p,q). Then
$$H\bigl(\overline{rs},S_\prec(r,s)\bigr) \leq2H\bigl(\overline{pq},S_\prec(p,q)\bigr).$$


We know that \(d(r,\overline{pq}) \leq H(\overline {pq},S_{\prec}(p,q)) =:h\) and \(d(s,\overline{pq}) \leq h\), therefore \(H(\overline {prsq},\overline{pq})\leq h\). Hence, for all \(v \in\overline{pq}\), \(d(v,\overline{prsq})\leq h\). Let tS (r,s)⊆S (p,q) and \(v \in \overline{pq}\) be such that \(d(t,v) = d(t,\overline{pq}) \leq h\). Using the triangle inequality we conclude \(d(t,\overline{prsq}) \leq d(t,v) +d(v,\overline{prsq}) \leq2h\). Because of (C2), we have \(d(t,\overline {rs}) =d(t,\overline{prsq}) \leq2h\), and therefore \(H(S_{\prec}(r,s),\overline{rs}) \leq2h\). □

Lemma 7

Let p,q,r,r′∈ℤ2, such that \(r_{x} - p_{x} =q_{x} - r'_{x} + \varepsilon\), \(r_{y} - p_{y} = q_{y} - r_{y}' - \varepsilon\), with ε∈{0,1,−1}, \(r'_{x} = r_{x}\) and \(r'_{y} = r_{y}+1\) (see Fig6). Then \(H(\overline{pq},\overline{prr'q}) \leq c = \sqrt{5}/2\).
Fig. 6

Two examples for the setup in Lemma 7


Without loss of generality, let p=(0,0, q x ≥0, and q y ≥0. We have
$$H\bigl(\overline{pq},\overline{prr'q}\bigr) = \max\bigl\{ d(r,\overline{pq}),d\bigl(r',\overline{pq}\bigr) \bigr\}.$$
By assumption, 2r x ε=q x and 2r y +ε+1=q y . So we get Similarly,
$$d\bigl(r',\overline{pq}\bigr) = \biggl|\frac{1}{2\sqrt {q_x^2 + q_y^2}} (q_y \varepsilon+ q_x \varepsilon- q_x )\biggr|.$$
Setting ξ:=q x /q y , we observe that no matter whether ε=0, ε=1, or ε=−1 as the function
$$f(\xi) = \frac{\xi+1/2}{\sqrt{\xi^2+1}}$$
attains its global maximum at ξ=2. □

The following lemma is a statement about the order ≺ and will be the key ingredient of the proof of Theorem 2.

Lemma 8

Let {x∈ℤ| Ax<B} be an interval of integers with the following properties:
  1. (i)

    Its number of elements is BA=2 k+1−1, for some number k,

  2. (ii)

    |(A+B−1)/2|2k, and for any other Ax<B, x≠(A+B−1)/2, we have |x|2<k.

Let \(x_{1} \prec x_{2} \prec\cdots\prec x_{2^{k+1} - 1}\) be the elements of the interval sorted in increasing order according to ≺. Then elements from the left half and elements from the right half of the interval alternate, that is, if x i <(A+B−1)/2 for some 1≤i<2 k+1−1, then x i+1≥(A+B−1)/2.


Define M:=(A+B−1)/2. Assume for a contradiction that there is an 1≤i<2 k+1−1 such that both x i <M and x i+1<M. First we look at the case that |A−1|2<|M|2. Then, on one hand, x i x i +2 k , because |x i j|2=|x i +2 k j|2 for all 0≤jx i A and |x i j|2=|A−1|2<|M|2=|x i +2 k j|2 for j=x i −(A−1). (We use the simple observation that if |x|2<k, then |x+2 k |2=|x|2.) But, on the other hand, x i +2 k x i+1, because there is a 0≤j 0x i A such that |x i +2 k j 0|2=|x i j 0|2<|x i+1j 0|2 and |x i +2 k j|2=|x i j|2=|x i+1j|2 for all 0≤j<j 0 (if the first j 0 such that |x i j 0|2 and |x i+1j 0|2 differ were j 0=x i A+1, then x i+1x i , because |A−1|2k). So x i x i +2 k x i+1, a contradiction.

In the case |A−1|2>|M|2, we can argue similarly that x i x i+1+2 k x i+1. (Note that equality never occurs, as |A−1|2=|M|2 implies |(A−1+M)/2|2≥|M|2k, but |(A−1+M)/2|2<k by assumption.)

We have shown that if x i <M, then x i+1M. Similarly, x i >M implies x i+1M. This follows directly by the pigeon-hole principle: Every x i <M has a unique successor x i+1>M and exactly half of the elements of [A,B)∖{M} are smaller than M, so there cannot be any x j >M whose successor is also greater than M. □

Now we are ready to prove our main result, Theorem 2, by showing that the CDS \(\mathcal{S}_{\prec}\) satisfies the condition (H).

Proof of Theorem 2

Let p,q∈ℤ2. We may assume that p x <q x and p y <q y . We are going to prove that \(H(\overline {pq},S_{\prec}(p,q))\leq2c\log(q_{x}+q_{y}-p_{x}-p_{y}) \) for \(c=\sqrt{5}/2\). Let rS (p,q) be the point with the property that r x +r y is the greatest element of the segment interval, that is, r x +r y s for all s∈[p x +p y ,q x +q y ), sr x +r y , see Fig. 7 for an example. Now let s′ be the second greatest element of the segment interval according to ≺. Define k:=|s′|2+1.
Fig. 7

The digital line segment from p=(2,3) to q=(7,5), with the ordered segment interval 8≻10≻6≻9≻5≻11≻7. The Euclidean segments \(\overline{pq}\) and \(\overline{prr'q}\) (dashed) can have Hausdorff distance at most c, as shown in Lemma 7

We can extend the segment S (p,q) over both endpoints, moving both p and q such that |p x +p y −1|2k and |q x +q y |2k, that is, we extend the segment as far as we can, so that k, defined as above, remains unchanged. From Lemma 6 we find that by this extension we decreased the Hausdorff distance by at most a factor of 2. Now the segment interval contains exactly 2 k+1−1 elements and r x +r y is the element in the very middle. We call such a segment normalized.

We are going to proceed by induction on k to prove that for all normalized digital line segments S (p,q), we have \(H(\overline {pq},S_{\prec}(p,q)) \leq ck \) with \(c = \sqrt{5}/2\). This will prove the theorem, as k+1=log(q x +q y p x p y +1), and then the distance of the unnormalized original segment (we started from) is at most 2ck=2c(log(q x +q y p x p y +1)−1)≤2clog(q x +q y p x p y ).

In the base case k=1, the segment interval consists of 3 numbers, so S (p,q) is a path of length 3 and by checking all possibilities we see that \(H(\overline{pq},S_{\prec}(p,q)) < c\).

If k>1, the idea is to split the segment at r into two subsegments that are similar in some sense and apply induction. Let r′=(r x ,r y +1) be the point that comes after r in the segment S (p,q). (We know that we go up at r, because we go up at least once and r x +r y is the greatest element of the segment interval.) Consider the subsegments S (p,r) and S (r′,q) and partition the segment interval accordingly. The key observation is that picking the elements of the interval according to ≺ starting with the greatest, we first get r, and then alternately an element of the left and the right subsegment interval. This is shown in Lemma 8, setting A=p x +p y , B=q x +q y . Therefore, up to a difference of at most one, half of the q y p y −1 greatest elements (after r x +r y ) belong to [p x +p y ,r x +r y ) and half of them to [r x +r y +1,q x +q y ). This implies that p,q,r,r′ meet the conditions of Lemma 7, leading to \(H(\overline{pq},\overline{prr'q}) \leq c\). By the induction hypothesis we have \(H(\overline{pr},S_{\prec}(p,r)) \leq c(k-1)\) and \(H(\overline{r'q},S_{\prec}(r',q)) \leq c(k-1)\). Now \(H(\overline{prr'q},S_{\prec}(p,q)) =\max\{H(\overline{pr},S_{\prec}(p,r)),H(\overline{r'q},S_{\prec}(r',q))\} \leq c(k-1)\). Using the triangle inequality we conclude \(H(\overline{pq},S_{\prec}(p,q))\leq ck\). □

4 A Step Towards a Characterization of CDSes

Now we approach the same problem from a different angle, taking arbitrary CDSes and trying to find some common patterns in their structure. Knowing that condition (C1) holds for all CDSes, it is easy to verify that we can analyze the segments with non-positive and non-negative slopes separately, as they are completely independent. More precisely, the union of any CDS on segments with non-positive slopes and another CDS on segments with non-negative slopes is automatically a CDS. Having this in mind, in this section we will proceed with the analysis of only one half of a CDS, namely of segments with non-negative slope.

We will show that, in a CDS, all the segments with non-negative slope emanating from a fixed point must be derived from a total order. However, as we will show later, these orders may differ for different points.

Theorem 9

For any CDS and for any point p=(p x ,p y )∈ℤ2, there is a total order p that is uniquely defined on both (−∞,p x +p y −1] and [p x +p y ,+∞), such that the segments with non-negative slope emanating from p are derived from p (in the way described in Sect2).


We fix a CDS \(\mathcal{S}\) and a point p. The segments with non-negative slope with p=(p x ,p y ) as their upper-right point will induce an order on the integers smaller than p x +p y , and the segments for which p is the lower-left endpoint will induce an order on the rest of the integers. In the following we will just look at the latter type of segments. First, we prove an auxiliary statement.

Lemma 10

In a CDS, it cannot happen that for two segments with non-negative slope having the same lower-left endpoint p, one of them goes up at (a,Ca) and the other goes right at (b,Cb), for some C and a>b.

Proof of Lemma 10

Let us, for a contradiction, assume the opposite, see Fig. 8. Now, we look at the ab+1 segments between the point p and each of the points on the line x+y=C between the points (a,Ca) and (b,Cb). It is possible to extend all of them through their upper-right endpoints, applying (S4). Note that each of the extended segments goes through a different point on the line x+y=C, and hence, because of condition (C3), no two of them can go through the same point on the line x+y=C+1. But there are only ab available points on the line x+y=C+1 between the points (a,Ca+1) and (b+1,Cb), one less than the number of segments, a contradiction.
Fig. 8

Two segments having p as their lower-left endpoint, one of them going up at (a,Ca) and the other going right at (b,Cb), with a>b


Coming back to the proof of the theorem, we define the relation ≺ p in the following way. Whenever there is a segment in \(\mathcal{S}\) with non-negative slope starting at p, going right at a point (x,Dx) and going up at a point (x′,Ex′), for some x and x′, we set D p E. This way we defined a relation on [p x +p y ,+∞), which is obviously irreflexive. To show that ≺ p is a total order, it remains to prove that it is asymmetric, transitive and total.

To show asymmetry, assume for a contradiction that for some integers D and E we have both D p E and E p D. That can happen only when there are two segments with non-negative slope having p as their lower-left endpoint, such that on the line x+y=D one of them goes up, the other right, and then on x+y=E they both go in different direction than at x+y=D. But then the situation described in Lemma 10 must occur on one of the two lines, a contradiction.

Next, if C p D and D p E, then we also have C p E – we just take a segment starting from p that goes right at C and up at D, and (if necessary) extend it until it passes the line x+y=E. It must also go up at E, because of D p E and the asymmetry of ≺ p . Hence, the relation ≺ p is transitive.

It remains to prove the totality of ≺ p . That is, for any pair of integers p x +p y D<E, either D p E or E p D holds. Consider a segment from p to some point q on the line x+y=E, such that this segment splits at q, that is, there are two extensions of the segment, one going up and another one going right. Such a segment exists since in the upper-right quadrant of p, the line x+y=E+1 contains one more point than the line x+y=E. If we look at all the segments between p and the points on x+y=E+1, the pigeon-hole principle ensures that two of them will contain the same point q on the line x+y=E. Now the segment S(p,q) crosses the line x+y=D at some point q′. Depending on whether it goes up or right at the point q′, either E p D or D p E holds. □

To see that these orders can differ for different points, consider the following example of a CDS, which we call the waterline example because of the special role of the x-axis. To connect two points with a segment, we do the following. Above the x-axis we go first right, then up, below the x-axis we go first up, then right, and when we have to traverse the x-axis, we go straight up to it, then travel on it to the right, and finally continue up, see Fig. 9. It is easy to check that this construction satisfies all five axioms.
Fig. 9

The waterline example: Examples of three characteristic segments, and the rays emanating from a point p, which is below the waterline

Now, if we consider a point p=(a,b) below the waterline, b<0, the induced total order ≺ p on [a+b,+∞) is a p a+1≺ p ⋯≺ p (+∞)≺ p a−1≺ p a−2≺ p ⋯≺ p a+b, and the order on (−∞,a+b−1] is a+b−1≺ p a+b−2≺ p ⋯≺ p −∞. If p is above the waterline, b≥0, the induced total orders are a−1≺ p a−2≺ p ⋯≺ p (−∞)≺ p a p a+1≺ p ⋯≺ p a+b−1 and a+b p a+b+1≺ p ⋯≺ p +∞. Obviously, there is no total order on ℤ compatible with these orders for all possible choices of p. For example, if we choose p=(a,b)=(1,−1), we get 1≺ p 0, but if we choose p=(a,b)=(−1,1), we get 0≺ p 1.

The special role played by the x-axis in the waterline example can be fulfilled by any other monotone digital line with a positive slope; above the line go right, then up, below the line go up, then right, and whenever the line is hit, follow it until either the x- or the y-coordinate matches that of the final destination, see Fig. 10. Again, it is straightforward to show that this way we obtain a CDS.
Fig. 10

A more exotic example of a CDS with an arbitrary “special” line (bold and dotted)

A way to see that such a CDS cannot be derived from a total order is to observe that now the diagonal translation of a digital line segment does not always yield another digital line segment, that is, these examples do not satisfy the condition from Observation 4. Actually, we can prove that it suffices to add this condition to force a unifying total order on all integers.

Theorem 11

Let \(\mathcal{S}\) be a restriction of a CDS to the set of all segments with non-negative slopes, such that for any t∈ℤ and any p,q∈ℤ2,
$$S\bigl(p+(t,-t),q+(t,-t)\bigr) = S(p,q) + (t,-t).$$
Then there is a unique total orderonsuch that \(\mathcal{S} =\mathcal{S}_{\prec}\).


Let p,q∈ℤ2. By Theorem 9, the segments starting at p define a unique total order ≺ p on [p x +p y ,∞), and similarly the segments starting at q define a unique total order ≺ q on [q x +q y ,∞). Let us suppose that q x +q y p x +p y . We want to check whether these two orders agree on [q x +q y ,∞). Assume for a contradiction that there are integers q x +q y A<B such that there is a segment S starting at p going to some point r, implying B p A, and another segment T starting at q, implying A q B, see Fig. 11 for an example. We translate the segment S diagonally by a vector (t,−t) until q lies on the translated segment S′ from p′ to r′. Then the subsegment from q to r′ still goes up at level A and to the right at level B, implying B q A, a contradiction.
Fig. 11

Two line segments leading to an inconsistency in the derived orders. After translating one of them diagonally (dashed) we get a contradiction

Therefore, we can define a unique total order ≺ as follows. To compare two integers A and B take any point p with p x +p y A and define AB if and only if A p B. By the argument above, this definition is independent of the choice of p and the arguments in the proof of Theorem 9 carry over to ≺, showing that it is a total order. □

5 Digital Lines

Even though our focus is on the digitalization of line segments, the present setup can be conveniently extended to a definition of digital lines. We say that a digital line is the vertex set of a path infinite in both directions in the ℤ2 base graph, such that the digital line segment between any two points on the digital line belongs to the digital line.

In this section we restrict our attention to CDSs that are derived from a total order as described in Sect. 2. Furthermore, for simplicity, we are only going to consider lines with non-negative slope, meaning that the Euclidean segment between any two points of the line has non-negative slope (including zero and infinity).

Consider a digital line derived from \(\mathcal{S}_{\prec}\). We define A ⊆ℤ to be the set of numbers x+y for which goes upward at (x,y) and call it the slope set of . Note that the slope set A is an interval in (ℤ,≺) which is unbounded in the increasing direction, i.e., if xA , then for any yx we have yA . This implies that there is a natural total order on the set of possible slope sets given by inclusion.

The following observation follows directly from the definition of S .

Observation 12

Every line can be described by its slope set A and a point p it contains. Also, given a point p, every ≺-interval A that is unbounded in the increasing direction is a valid slope set of a line through p, that is, there is a line such that p and A =A.

It follows directly from Theorem 3 that two lines having a point in common cannot split and then meet later. Similarly, two lines cannot meet and split without crossing. (If they did, by Observation 4 we could translate one of them diagonally to produce a contradiction with axiom (S3).)

Observation 13

If two different lines intersect, then they either cross, having a common segment, or they have a common half-line.

Lemma 14

Consider two different slope sets A and B with AB. Let I=BA be the difference of the slope sets.
  1. (1)

    If I is finite, then there are lines l and s such that A l =A, A s =B and l and s intersect in a lower-left halfline and there are lines l′, swith slope sets A l=A, A s=B intersecting in an upper-right halfline.

  2. (2)

    If I is infinite and bounded in one direction in the natural order on ℤ, then we can find lines l and s with slope sets A and B intersecting in a lower-left or an upper-right halfline, depending on whether I is lower- or upper-bounded with respect to the natural order.

  3. (3)

    If I is unbounded in both directions, then all lines l and s with slope sets A and B do intersect in a finite segment.



If I is finite, let c be its smallest element according to the natural order. Let p be a point with p x +p y =c. Construct the line l with slope set A through p and the line s through p with slope set B. To the lower left of p, l and s coincide, because for all zp x +p y (in the natural order), zA if and only if zB. Similarly, picking a point q such that q x +q y equals the biggest element of I in the natural order, one can construct the line with slope set A and the line with slope set B through q. These two lines are going to coincide to the upper right of q.

If I is infinite and there is a k∈ℤ such that for all iI, i<k, then pick a point p with p x +p y =k. The line l with slope set A through p and the line s with slope set B through P have the halfline starting at p in common, because for all z∈ℤ with zk, z is in A if and only if z is in B.

Finally, consider lines l and s with slope sets AB such that I=BA is unbounded in both directions according to the natural order. For any point pl, look at the corresponding point p′∈s on the same level, that is, with \(p'_{x} + p'_{y} = p_{x} +p_{y}\). Moving p on l toward the upper right, the difference \(p_{y} -p'_{y} = p'_{x} - p_{x}\) decreases monotonically. (Whenever p x +p y I, p is moving to the right, but p′ is moving up, so \(p_{y} - p'_{y}\) decreases by one.) The same way, the difference increases from time to time if we move p on l into the other direction. Because I is unbounded both ways, there is no point after which the difference remains constant moving to the upper right, nor a point after which the difference remains constant moving p to the lower left. Therefore, l and s have to intersect in a common line segment. □

We define two lines to be parallel if they do not cross, that is, according to Observation 13, two lines are parallel if they are disjoint or if they agree on a halfline. We distinguish two possible cases for the slope sets A of a line . If there is a c∈ℤ such that A =[c,∞)={a∈ℤ| ac}∪{c} or A =(c,∞)={a∈ℤ| ac}, that is, if its boundary can be described by the smallest element, either including or excluding this element, then we call the slope set A rational. In the special cases A =ℤ and A =∅ we define A as rational, too. If no such c exists, or, in other words, if A does not have a smallest element and its complement ℤ∖A does not have a greatest element (and they are not empty), then we call A irrational.

We proceed by analyzing the digital lines derived from the total order that we defined in Sect. 3, using the powers of 2. We denote this order by ≺. With the help of the previous lemma, we can characterize which lines do have unique parallels and which do not.

Theorem 15

Let be a line with respect to \(\mathcal{S}_{\prec^{*}}\), and let p∈ℤ2 be a point with p.
  1. (1)

    If the slope set A is irrational, then there is a unique line through p that is parallel to . Furthermore, A =A .

  2. (2)

    If A is rational, then has exactly two parallels and through p, one of them with the same slope set as , the other with a slope set that differs by one element. Consequently and have a common halfline in one direction, and split at one point to run parallel at distance one in the other direction.



Note that ≺ is a dense order on ℤ, that is, for any two integers a b, we find a c∈ℤ such that a c b. Equivalently, this means that every ≺-interval \([a,b]_{\prec^{*}}\) with ab is infinite. Let s be an arbitrary line through p parallel to . Consider the symmetric difference of the slope sets I=A A s . If I is empty, the slope sets are equal and s is the diagonal translate of going through p. If I≠∅, by density of the order, I is either infinite or consists only of one element a. If I is infinite, then it is unbounded according to the natural order in both directions. (Besides density, this is the only property of ≺ that we use.) According to Lemma 14, s and do intersect in a finite segment in this case, which is a contradiction because s is parallel to . Therefore, I consists of one element. If A is irrational, by adding one element to A or removing one element from A we do not get a ≺-interval. Hence, in this case, there is only one possible slope set for any line parallel to , namely, A . If A is rational, then either A ={a∈ℤ| c a}∪{c} or A ={a∈ℤ| c a}, for some c∈ℤ, so adding c or removing c, respectively, yields the only different possible slope set for a parallel through p. As the slope sets of these two parallels differ by only one element, they have either a common halfline to the left or a common halfline to the right. □

6 Higher Dimensions

It is natural to ask whether there is a CDS in more than two dimensions. The definition of a CDS directly carries over to the higher dimensional spaces. Instead of ℤ2 we now consider ℤ d , for a fixed integer d≥3, with the usual graph structure, that is, two points p and q are adjacent if they differ in exactly one coordinate by exactly one. The axioms (S1)–(S4) stay the same, verbatim, and the monotonicity axiom (S5) now reads as follows: If for p=(p 1,…,p d ),q=(q 1,…,q d )∈ℤ d there is an i such that p i =q i , then for all r=(r 1,…,r d )∈S(p,q) we have r i =p i =q i . We define the slope type of a pair of points (p,q) as the sign vector (σ 1,…,σ d )∈{+1,−1} d , σ i =+1, if p i q i , and σ i =−1, if p i >q i . The slope type of a digital segment S(p,q) is defined as the slope type of (p,q). We say that a segment has strictly positive slope, if its slope type is (+1,…,+1), that is, the coordinates are monotone increasing in each coordinate.

It is not hard to see that we can again derive a consistent system from an arbitrary total order ≺ on ℤ, if we consider only segments that have strictly positive slope, that is, slope type (+1,…,+1); the only difference in the construction is that now we have to cut the segment interval [p 1+⋯+p d ,q 1+⋯+q d −1] into d parts, according to ≺. Let p,q∈ℤ d be two points, such that p i q i for all 1≤id. We can define the segment S (p,q) in a similar way as in the two dimensional case—starting at p and repeatedly going in one of the d possible directions, collecting points from ℤ d , until we reach q. If we are at a point (r 1,…,r d ) for which r 1+r 2+⋯+r d is among the q d p d greatest elements of the segment interval [p 1+⋯+p d ,q 1+⋯+q d −1] according to ≺, we proceed in direction d; if it is among the q d−1p d−1 greatest elements of the segment interval that remain after removing the q d p d elements that were the greatest, we proceed in direction d−1, and so on. Finally, if r 1+r 2+⋯+r d is among the q 1p 1 smallest elements of the segment interval, we proceed in direction 1.

Theorem 16

The definition above yields a CDS of segments with strictly positive slope.


The crucial axiom to verify is the subsegment property (S3). As in the proof of Theorem 3, assume there are two segments with strictly positive slope, splitting at some point p and meeting again for the first time at q (see Fig. 3). The two subsegments from p to q can be seen as words over the alphabet [d]={1,2,…,d}, where 1 stands for going in the first direction, 2 for going in the second direction, and so on. So let α=a 1 a 2a k ,β=b 1 b 2,…,b k ∈[d] k be these two words. By assumption they differ at the beginning and at the end and they contain the same number of each of the letters, that is, for any l∈[d], |{i:a i =l}|=|{i:b i =l}|. Without loss of generality we may assume that a 1>b 1. Then there must be an 1<ik such that a i <a 1 and b i >b 1. (If there were no such i, then for any 1<ik with a i <a 1 we have b i b 1<a 1. Now looking at all letters that are strictly smaller than a 1 in both words, we see that there is at least one such letter more in b, namely at the first position, a contradiction.) This leads to a contradiction, as translated back to the original setting it implies p 1+⋯+p d p 1+⋯+p d +i−1, if we look at the interval of the first segment, and at the same time p 1+⋯+p d p 1+⋯+p d +i−1, if we look at the interval of the second segment. This proves (S3).

The rest of the axioms can be verified similarly as in the 2-dimensional case. □

Of course, we can use the same construction to define segments for all the remaining slope types. However, unlike in the 2-dimensional case, putting them all together in an attempt to construct a complete CDS fails in general, as the axiom (S3) might be violated, see Fig. 12 for a possible conflict.
Fig. 12

Two digital line segments, from p to q (solid) and from r to s (dashed), violating the subsegment property (S3)

7 Conclusion

The main result of this paper is the construction of a CDS in the plane with the property that the digital segments are reasonably close, in the Hausdorff metric, to their Euclidean counterparts. The solution we provide is optimal up to a constant factor. The key idea is to derive a CDS from a total order on ℤ.

It is shown that adding an additional constraint, namely translation invariance in the diagonal direction, there is a one to one correspondence between CDSes and total orders on ℤ. However, there remain “exotic” examples not satisfying this condition, like the waterline example presented in Sect. 4, which consequently are not derived from a total order. Are there other “exotic” examples? How can we completely characterize all consistent digital line segment systems in the plane?

Moving to higher dimensional spaces, the trivial CDSes following the axis-parallel box spanned by the two end points naturally generalize. Also, one can generalize the waterline example—in three dimensions, for example, we can define a CDS as follows. For points p and q, suppose that p is farther away from the plane z=0 than q. Starting at p, we first move towards the z=0 plane vertically, until either the z-coordinate equals q z or we hit the plane z=0. Then we move horizontally, following some planar CDS, until we are on the same vertical line as q. Finally, if necessary, we move away from the z=0 plane vertically to reach q. Note that, just like their planar counterparts, these systems do not satisfy the small Hausdorff distance property (H).

Our approach using total orders remains applicable if we restrict to consistent digital rays emanating from one common point or if we only allow segments of a certain slope type. However, when trying to combine systems with different slope types, it seems inevitable to violate property (S3), as shown in Fig. 12, unless we use systems derived from very special total orders, in which case the system does not satisfy property (H). Hence, the question if there is a CDS satisfying the small Hausdorff distance property (H) in dimension higher than two remains open.



We are indebted to Jiří Matoušek, who posed this problem at the 7th Gremo Workshop on Open Problems—GWOP 2009. We would like to thank József Solymosi for participating in the fruitful discussions that led to the main result of this paper. We thank the organizers of GWOP 2009 for inviting us to the workshop and providing us with a gratifying working environment. Finally, we are grateful to the anonymous referees, whose useful and detailed comments improved our paper a lot.

M. Stojaković was partly supported by Ministry of Science and Technological Development, Republic of Serbia, and Provincial Secretariat for Science, Province of Vojvodina.


  1. 1.
    Chun, J., Korman, M., Nöllenburg, M., Tokuyama, T.: Consistent digital rays. Discrete Comput. Geom. 42(3), 359–378 (2009) MathSciNetzbMATHCrossRefGoogle Scholar
  2. 2.
    Goodrich, M.T., Guibas, L.J., Hershberger, J., Tanenbaum, P.J.: Snap rounding line segments efficiently in two and three dimensions (1997) Google Scholar
  3. 3.
    Greene, D.H., Yao, F.F.: Finite-resolution computational geometry. In: FOCS’86: Proceedings of the 27th Annual Symposium on Foundations of Computer Science, Washington, DC, USA, pp. 143–152. IEEE Comput. Soc., Los Alamitos (1986) Google Scholar
  4. 4.
    Klette, R., Rosenfeld, A.: Digital straightness—a review. Discrete Appl. Math. 139(1–3), 197–230 (2004) MathSciNetzbMATHCrossRefGoogle Scholar
  5. 5.
    Schmidt, W.M.: Irregularities of distribution. VII. Acta Arith. 21, 45–50 (1972) MathSciNetzbMATHGoogle Scholar
  6. 6.
    Sugihara, K.: Robust geometric computation based on topological consistency. In: Alexandrov, V.N., Dongarra, J., Juliano, B.A., Renner, R.S., Tan, C.J.K. (eds.) International Conference on Computational Science (1). Lecture Notes in Computer Science, vol. 2073, pp. 12–26. Springer, Berlin (2001) Google Scholar
  7. 7.
    van der Corput, J.: Verteilungsfunktionen. I. Mitt. Proc. Akad. Wet. Amsterdam 38, 813–821 (1935) Google Scholar

Copyright information

© Springer Science+Business Media, LLC 2012

Authors and Affiliations

  • Tobias Christ
    • 1
  • Dömötör Pálvölgyi
    • 2
  • Miloš Stojaković
    • 3
    Email author
  1. 1.Institute of Theoretical Computer ScienceETH ZurichZurichSwitzerland
  2. 2.Department of Combinatorial GeometryEPF LausanneLausanneSwitzerland
  3. 3.Department of Mathematics and InformaticsUniversity of Novi SadNovi SadSerbia

Personalised recommendations