Consider the following scenario:

I have a line segment in 3d to track an ideal approach to a given runway. Aircraft's objective is to try to fly ON this particular line into the touchdown zone, however, no one is perfect, and players will inevitably fly too high, too low, to far to the left, or too far to the right of this line.
My goal is to identify if a player is too high, too low, too too far to the left, or too far to the right. and do something if the player is too far in any given side (this includes printing to the player that they're too high or too low).
The question: (Considering the above illustration:) If I have a given a cartesian line segment in 3d space (line = x, y, z && line2 = x1, y1, z1) and a player's point relative to the line (also in 3d space), does it make sense / is it practical to convert the 3d line to a singular point on its own axis (origin 0, 0) and measure the distance to the player's point relative to the origin? If so, how could I approach converting this 3d line in a fixed dimension to a point in a separate dimension.
My thought process: Every 2d line can be represented as a point in 1d so long as we're looking down the line. If we do this and make that point the origin of a 2d grid, measuring relative distance becomes easy.
I think it's possible to also use other methods / approaches such as cross products, but if this is cheaper, I'd prefer to use this method.
Anyways, I'd love to hear your feedback. Please let me know what you think! Note: I'm using lua
I've seen some mentions of homogenous coordinates, but I've noticed that because the axis is fixed despite a desired rotated axis, it causes issues in various conditions.
Measuring a distance to closest point on the line is simple, but not so much when trying to identify if it's left or right / up or down relative to the line.
create basis vectors
Xright,Yupyou can use local ground normal
n, line(p0,p1)direction and cross product to do thisconvert
now
x,yis signed distance from your line aligned to your wanted directions...[edit1] moved from comments...
Anyway if you want signed scalar distance
dalong some unit vectorvfrom some starting pointp0of some pointpthen it is:now you just provide vector
valong whatever you want to measure the distance. As your ground is planez=0using parametric circle equation (usingazimuthas parameter) you get vector along your runwayif you want the vector left/right you just rotate it by 90 deg so either use
azimuth + PI/2or swapx,yand negate one for exampleif you want up vector its just
(0,0,1)From what you describe now you want axis
Yto be perpendicular to your approach line(p0,p1)and point up (angled) so you can exploit cross product which will return perpendicular vector to its operands so:the internal cross
cross(p1-p0,(0,0,1))will be the same asXif the approach line is aligned to your runway...