# Direction-preserving function

In discrete mathematics, a direction-preserving function (or mapping) is a function on a discrete space, such as the integer grid, that (informally) does not change too drastically between two adjacent points. It can be considered a discrete analogue of a continuous function.
The concept was first defined by Iimura. Some variants of it were later defined by Yang, Chen and Deng, Herings, van-der-Laan, Talman and Yang, and others.

## Basic concepts

We focus on functions $f:X\to \mathbb {R} ^{n}$, where the domain X is a finite subset of the Euclidean space $\mathbb {R} ^{n}$. ch(X) denotes the convex hull of X.
There are many variants of direction-preservation properties, depending on how exactly one defines the "drastic change" and the "adjacent points". Regarding the "drastic change" there are two main variants:
* Direction preservation (DP) means that, if x and y are adjacent, then for all $i\in [n]$: $f_{i}(x)\cdot f_{i}(y)\geq 0$. In words: every component of the function f must not switch signs between adjacent points.
* Gross direction preservation (GDP) means that, if x and y are adjacent, then $f(x)\cdot f(y)\geq 0$. In words: the direction of the function f (as a vector) does not change by more than 90 degrees between adjacent points. Note that DP implies GDP but not vice versa.
Regarding the "adjacent points" there are several variants:
* Hypercubic means that x and y are adjacent iff they are contained in some axes-parallel hypercube of side-length 1.
* Simplicial means that x and y are adjacent iff they are vertices of the same simplex, in some triangulation of the domain. Usually, simplicial adjacency is much stronger than hypercubic adjacency; accordingly, hypercubic DP is much stronger than simplicial DP.
Specific definitions are presented below. All examples below are for $n=2$ dimensions and for X = { (2,6), (2,7), (3, 6), (3, 7) }.

## Properties and examples
### Hypercubic direction-preservation

A cell is a subset of $\mathbb {R} ^{n}$ that can be expressed by $k+[0,1]^{n}$ for some $k\in \mathbb {Z} ^{n}$. For example, the square $[2,3]\times [6,7]$ is a cell.
Two points in $\mathbb {R} ^{n}$ are called cell connected if there is a cell that contains both of them.
Hypercubic direction-preservation properties require that the function does not change too drastically in cell-connected points (points in the same hypercubic cell).
| f$^a$ | 6 | 7 |
| 2 | (2,1) | (1,1) |
| 3 | (0,1) | (0,0) |
f is called hypercubic direction preserving (HDP) if, for any pair of cell-connected points x,y in X, for all $i\in [n]$: $f_{i}(x)\cdot f_{i}(y)\geq 0$. The term locally direction-preserving (LDP) is often used instead. The function f$^a$ on the right is DP.
* Some authors$^{:Def.1}$ use a variant requiring that, for any pair of cell-connected points x,y in X, for all $i\in [n]$: $(f_{i}(x)-x_{i})\cdot (f_{i}(y)-y_{i})\geq 0$. A function f(x) is HDP by the second variant, iff the function g(x):=f(x)-x is HDP by the first variant.
| f$^b$ | 6 | 7 |
| 2 | (2,1) | (1,1) |
| 3 | (1,-1) | (0,0) |
f is called hypercubic gross direction preserving (HGDP), or locally gross direction preserving (LGDP), if for any pair of cell-connected points x,y in X, $f(x)\cdot f(y)\geq 0$.$^{:Def.2.2}$ Every HDP function is HGDP, but the converse is not true. The function f$^b$ is HGDP, since the scalar product of every two vectors in the table is non-negative. But it is not HDP, since the second component switches sign between (2,6) and (3,6): $f_{2}^{b}(2,6)\cdot f_{2}^{b}(3,6)=-1<0$.
* Some authors use a variant requiring that, for any pair of cell-connected points x,y in X, $(f(x)-x)\cdot (f(y)-y)\geq 0$. A function f(x) is HGDP by the second variant, iff the function g(x):=f(x)-x is HGDP by the first variant.

### Simplicial direction-preservation

A simplex is called integral if all its vertices have integer coordinates, and they all lie in the same cell (so the difference between coordinates of different vertices is at most 1).
A triangulation of some subset of $\mathbb {R} ^{n}$ is called integral if all its simplices are integral.
Given a triangulation, two points are called simplicially connected if there is a simplex of the triangulation that contains both of them.
Note that, in an integral triangulation, every simplicially-connected points are also cell-connected, but the converse is not true. For example, consider the cell $[2,3]\times [6,7]$. Consider the integral triangulation that partitions it into two triangles: {(2,6),(2,7),(3,7)} and {(2,6),(3,6),(3,7)}. The points (2,7) and (3,6) are cell-connected but not simplicially-connected.
Simplicial direction-preservation properties assume some fixed integral triangulation of the input domain. They require that the function does not change too drastically in simplicially-connected points (points in the same simplex of the triangulation). This is, in general, a much weaker requirement than hypercubic direction-preservation.
f is called simplicial direction preserving (SDP) if, for some integral triangulation of X, for any pair of simplicially-connected points x,y in X, for all $i\in [n]$: $(f_{i}(x)-x_{i})\cdot (f_{i}(y)-y_{i})\geq 0$.$^{:Def.4}$
| f$^c$ | 6 | 7 |
| 2 | (2,1) | (1,1) |
| 3 | (1,-2) | (0,0) |
f is called simplicially gross direction preserving (SGDP) or simplicially-local gross direction preserving (SLGDP) if there exists an integral triangulation of ch(X) such that, for any pair of simplicially-connected points x,y in X, $f(x)\cdot f(y)\geq 0$.
Every HGDP function is SGDP, but HGDP is much stronger: it is equivalent to SGDP w.r.t. all possible integral triangulations of ch(X), whereas SGDP relates to a single triangulation.$^{:Def.2.3}$ As an example, the function f$^c$ on the right is SGDP by the triangulation that partitions the cell into the two triangles {(2,6),(2,7),(3,7)} and {(2,6),(3,6),(3,7)}, since in each triangle, the scalar product of every two vectors is non-negative. But it is not HGDP, since $f^{c}(3,6)\cdot f^{c}(2,7)=-1<0$.