Definition 1: A "fence" is a set of "fence post positions", where each pair of adjacent positions has the same difference (the spacing), e.g. $\{1,2, 3, 4\}$.
A fence is described by three values ($\in \mathbb{R}$): lower bound ($l$), upper bound ($u$) and spacing ($s$), with $l \leq u$ and $s > 0$.
$Fence(l,u,s)=\{x|x=l+n \cdot s, n \in \mathbb{N_0}, x \le u \}$
Definition 2: For two fences $X$ and $Y$, their distance $\Delta(X,Y)$ is the sum of all $|x-y|$ for each $x \in X$ (that is also $\in [Y_l,Y_u]$) and the closest corresponding $y \in Y$.
The problem: Three fences $A$, $B$ and $C$ are given. Find a value for $C_s$ that satisfies the following conditions:
- $C$ is the best approximation of both $A$ and $B$: $C_s$ minimizes $\Sigma\Delta = \Delta(A,C)+\Delta(B,C)$.
- $C_s$ is not smaller than the smallest possible spacing: $C_s \geq \mu$.
- If there are several solutions, then the spacing should be as large as possible (to minimize the number of fence posts).
For some special cases this is easy, e.g. $A_l = B_l = C_l \land A_s \bmod{B_s} = 0 \Rightarrow C_s = B_s$. But I am struggling to find a general solution and don't really know where to start.
Remarks: All values can be assumed to be multiples of $\mu$. This allows us to discretize the problem, so that all bounds are $\in \mathbb{Z}$ and all spacings $\in \mathbb{N}$. This somewhat simplifies the problem by making it possible to enumerate and compare all possible values for $C_s$. But due to its bad computational complexity, I want to avoid such a brute-force search algorithm. I'm looking for a a closed form expression (if it exists) or a better algorithm.
Application: In case you are wondering, I need to write an algorithm that combines two measurements of a spatial light sensor (goniophotometer) and I want the new scan grid to closely resemble the original ones in ordner to minimize interpolation and loss of information (e.g. local intensity peaks).