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.
You can use either the x or the y value of the intersection to compute the z-value (using x):
t = (x - X1) / (X2 - X1) z = Z1 + (Z2 - Z1) * t
Where x is the x-intersection. X1, X2 and Z1, Z2 are your known x and z-values, respectively, of the segment's endpoints.