Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate the Z of a line intersection given the XY coordinates?

I'm intersecting a line in 2D and I calculate the X,Y coordinates of the intersection point. What I need is the Z of the intersection point given the X,Y,Z of the line points, and the X,Y of the intersection. From what I understand of equations it should be a one-liner but I don't know enough math to get there.

like image 650
Robin Rodricks Avatar asked Dec 08 '25 12:12

Robin Rodricks


1 Answers

Your question is rather vague, but I will try to answer.

So take following equation:

3d line equation

Let's note it as Fx(X) = Fy(Y) = Fz(Z) and take a part of it:

  • Fx(X) = Fz(Z)

Then you said you know x, y and z for two points, put it to x1, x2, z1, z2 accordingly. Then put x of intersection to x. Now you have a linear equation with one variable z. Here it is:

z = (x - x1) / (x2 - x1) * (z2 - z1) + z1
like image 176
Andrey Avatar answered Dec 12 '25 00:12

Andrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!