Please bear with me, this is my first question here and I hope it fits and is understandable.
I want to construct a "curved" grid on the screen in a computer program.
Visualization of the curved grid
The grid shall consist of a parametric x-/y-baseline curve, perpendiculars to that curve in regular arc length intervals, and then curves which are "parallel" to the baseline and again orthogonal to the perpendiculars.
We shall not consider the case that any of the perpendiculars intersect with each other. This is ensured not to happen by preconditions.
The baseline (bottom-most green curve in the picture):
The user interactively defines $N$ points $\mathbf{P}_i = (x_i, y_i)$ with $i = 1, ..., N$ (marked with small squares in the image above).
With these, I perform natural cubic spline interpolation to determine two splines $x(t)$ and $y(t)$, and subsequently the parameterized baseline curve $\mathbf{B}(t) = (x(t), y(t))$ with real-valued $t \in [0, N]$. The boundary conditions of the interpolations are chosen such that the 2nd derivatives vanish at $t=0$ and $t=n$.
$t$ and $\mathbf{B}(t)$ are defined such that $\mathbf{B}(t=0) = \mathbf{P}_0, \mathbf{B}(t = 1) = \mathbf{P}_1$, etc.
The perpendiculars:
Next, I calculate line segments which are perpendicular to the $\mathbf{B}(t)$ curve at regular arc length intervals $l$. For this, I start at $t_0 = 0$ and find $t_{i+1} = t_i + \Delta t_i$, as long as $t_{i+1} \le N$, such that: $$l = \int\limits_{t_i}^{t_{i+1}} \sqrt { \left( \frac{dx}{dt} \right)^2 + \left( \frac{dy}{dt} \right)^2 } dt $$
Calculation of the integral is done numerically, and I solve for $\Delta t_i$ using a Newton iteration with a bisection method as fallback (sometimes my initial guess is too bad and Newton does not converge).
Eventually, this leads to $M$ values $t_0, t_1, ..., t_M$, for which I have $\mathbf{B}(t_i)$ as the starting point of the perpendicular line, $\mathbf{B}'(t_i) := \left( \frac{dx}{dt}(t_i), \frac{dy}{dt} (t_i) \right)$ as the slope, and thus $ \left( -\frac{dy}{dt}(t_i), \frac{dx}{dt}(t_i) \right) $ as a direction vector for the $i$-th perpendicular.
The length of each perpendicular line is just some constant $c$.
The curved gridlines:
Finally, I construct "parallel" curves to the baseline by interpolating between matching points on the perpendiculars.
I.e. choose any constant $\tau \in [0, 1]$ and for each perpendicular line $\mathbf{L}_i$ with start point $\mathbf{a}_i$ and end point $\mathbf{b}_i$, let $\mathbf{c}_i(\tau) = \mathbf{a}_i + \tau \cdot (\mathbf{b}_i - \mathbf{a}_i)$.
For the sake of simplicity, consider only one such curve with $\tau := 1$ so that $\mathbf{c}_i(\tau) = \mathbf{b}_i$ with $i = 0, ..., M$ identifies the end point of each perpendicular line.
The associated curved gridline is then found by again performing cubic spline interpolations for the $x$- and $y$-components. Let's call this curve $\mathbf{C}(s) := \left( c_x(s), c_y(s) \right)$ with $s \in [0, M]$. Thus, for $s_0 = 0, s_1 = 1, ..., s_M = M$ it follows that $\mathbf{C}(s_i) = \mathbf{b}_i$ identifies the intersections between the curve $\mathbf{C}$ and the perpendicular lines $\mathbf{L}_i$.
The problem:
While the perpendicular lines $\mathbf{L}_i$, by construction, are orthogonal to the baseline $\mathbf{B}(t)$, they are in general not orthogonal to the curved gridlines $\mathbf{C}(s)$.
Initially, my idea was to use a slope-based spline interpolation (Hermite) for $\mathbf{C}(s)$ such that at $s_0, s_1, ...$ not only the points $\mathbf{C}(s_i) = \mathbf{b}_i$ are prescribed, but also the first derivatives which follow from the slope of the perpendicular line $\mathbf{L}_i$. But the slope/perpendiculars only provide me with a $\frac{dx}{dy}$ relation, where as the curve $\mathbf{C}(s) := \left( c_x(s), c_y(s) \right)$ is evidently a function in $s$.
At the baseline $\mathbf{B}(t)$, I do know the derivatives $\frac{dx}{dt}$ and $\frac{dy}{dt}$ at each point $t$, but since I do not know the relation between the curve parameters $s$ and $t$, I cannot infer $dc_x/ds$ or $dc_y/ds$.
What can I do?