Finding An Arbitrary Intersection Point Between Two N-Dimensional Planes

Discussion in 'Advanced Programming Discussion' started by Tirous, Sep 16, 2017.

1. TirousMember

Joined:
Jun 21, 2016
Posts:
73

Recently I've been trying to find out how to find a point of intersection between two n-dimensional planes ('a' instead of 'the', as 3D intersections use lines and thus infinite points).

I've devised a way from scratch (like a big boy) and want ya'll to critique it and help me improve upon it and iterate.

I've also drawn up a rough diagram, who's variables and client maths I'll explain shortly. The constants here are p, n, p', and n'. p is an arbitrary point on the first plane, and n is it's surface normal, p' and n' are similarly that but of the second plane. The goal is to find I, which is an intersection between the first and second plane, or proof that it doesn't exist, or could be expressed by any point on either plane (making it worthlessly broad).

The derived values here are j, which is a version of p, projected onto the second plane; d, which is the magnitude of j's projection; t, which is a further projected version of j back onto the first plane; i, which is the magnitude of t's projection; and finally t', which is a normal perpendicular to n and who's creation is the sole reason for variables like t.

Here's the equation (sorry if my notation's a tad odd), as always, vector multiplication is the dot-product, absolute values of vectors are their lengths (at least to me they've always been):

If |nn'| = 1 —› No meaningful I exists.

If (p' - p)n < 0 —› Invert n to -n.
If (p - p')n' < 0 —› Invert n' to -n'.

I = (t' ÷ |t'(-n')|)d + p

t' = (t - p) ÷ |t' - p|
d = |j - p|

t = -ni + j
j = -n'(p' - p) + p
i = |(j - p)n'|

* In 3D you can use "t' × n" to find a normal that when paired with I can be used to properly describe the line that is their intersection.

So ya, hoping for critique and for ya'll to help explain to me how I've almost certainly screwed this up, or at least deeply overcomplicated it.

PS. If there's a better place to put this, plz get a mod to move it there! Last edited: Sep 16, 2017
2. FrostyCatMember

Joined:
Jun 26, 2016
Posts:
4,033
Yes, you've over-complicated this big-time. Linear algebra would have made much quicker work of this than vector addition.

Had you treated this as a system of 2 linear equations: Then reducing the augmented matrix (shown below) to RREF would have revealed how many solutions there are, as well as one of the collision points. • Bottom row reduced to [0, 0, 0, NONZERO]: No solution.
• Bottom row reduced to [0, 0, 0, 0]: Coincident planes. Plane base points p0 and p1 are both solutions.
• Full rank: Planes intersect in a line. The easiest solution point has 0 corresponding to the unreduced component (column 1 is x, column 2 is y, column 3 is z), and the two entries on the augmented column corresponding to the reduced components (see: kernel (AKA nullspace)).

There's a good reason why I don't let people near 3D without linear algebra. If you asked a question like this on a forum for a 3D engine, even the amateurs would have given you weird looks almost right away.

Tirous likes this.
3. TirousMember

Joined:
Jun 21, 2016
Posts:
73
Lol, I see... thx m8!

That said, I know only the most surface level concepts of linear algabra; so could you maybe explain your math to me in a less assuming way? ... cuz i suk. Also, if overcomplicated; would my original math still work? Or is it overcomplicated AND wrong?