Simple intersection of a straight line on a fixed z axis?

What is there, and is there a quick way to check where on the plane my line will intersect if I know that the plane is always on the same z axis (so it cannot be rotated) and its width / height is infinite? In addition, my β€œline” is not really a line, but a 3D vector, so the β€œline” can go to infinite distance.

Here is a code that relies on two points: (p1 and p2 are the start and end points of the line. Plane_z = where is the plane)

k1 = -p2.z/(p1.z-p2.z-plane_z);
k2 = 1.0f-k1;
ix = k1*p1.x + k2*p2.x;
iy = k1*p1.y + k2*p2.y;
iz = plane_z; // where my plane lays

Another solution that works with a vector (I made it using two points, as the first example did, "p2.x-p1.x", etc. - vector calculation):

a = (plane_z-p1.z)/(p2.z-p1.z);
ix = p1.x + a*(p2.x-p1.x);
iy = p1.y + a*(p2.y-p1.y);
iz = plane_z;

Edit3: Orbling, , .

+3
1

, http://paulbourke.net/geometry/planeline/, . (# 2) A B ( )

z ( )

: , ?

+3

All Articles