With the two points in $\mathbb{R}^3$ given by $$ (x_1=18.1009988576007, y_1=8.98615800401940, z_1=0.0383777665716703)$$ $$(x_2=18.1467590941979, y_2=9.05076591949910, z_2=-0.0425807020243865)$$ I want to interpolate this and get the value of $x$ and $y$ when $z = 0$. I don't know how I should it.
Thanks!
This is simple linear interpolation.
You have two points: $(x_0, y_0, z_0)$ and $(x_1, y_1, z_1)$. If we draw a line that passes through the two points, we can use $t$ to parametrise the line. Each value of $t$ then names a specific point on the line.
I used subscripts $0$ and $1$ for the coordinates, because the easiest parametrisation is such that $t = 0$ at $(x_0, y_0, z_0)$, and $t = 1$ at $(x_1, y_1, z_1)$: $$\begin{cases} x(t) &=& (1 - t) \; x_0 + t \; x_1 &=& x_0 + t \; (x_1 - x_0) \\ y(t) &=& (1 - t) \; y_0 + t \; y_1 &=& y_0 + t \; (y_1 - y_0) \\ z(t) &=& (1 - t) \; z_0 + t \; z_1 &=& z_0 + t \; (z_1 - z_0) \end{cases}$$
If you want to know the coordinates when $z = z(t)$, just solve for $t$: $$\begin{array}{lrcl} \; & z & = & z_0 + t (z_1 - z_0) \\ \iff & z - z_0 & = & t (z_1 - z_0) \\ \iff & t & = & \frac{z - z_0}{z_1 - z_0} \end{array}$$
If the line is parallel to the $z$ axis, $z_1 = z_0$, the above becomes a division by zero; then, $t$ is undefined. This is perfectly understandable, since the line being parallel to the $z$ axis, $z(t) = z_1 = z_0$ everywhere: if $z = z_0 = z_1$, then any $t$ is acceptable; otherwise no $t$ will yield $z(t) = z$.
You can solve for $t$ in the other coordinates, too, exactly the same way.
After you find the $t$, just plug it back in to the equations above, to get the values of the other coordinates.