# Normalised XY of a point on a planar quad

The solution to this is probably really simple, I just can’t think of it right now and was wondering if someone could help.

I have a quad defined by four points in 3D space. It is planar, but the edges are not necessarily parallel. If I take them as two pairs, linear interpolate along both, and then between the results using a normalised X and Y value, I can get any position within the quad with those two values. Question is, how do I go the other way around? If I can get a point in 3D I know for sure is in that quad, how can I get the normalised X/Y? Whenever I try and solve it mentally and solution requires that I determine one axis using the result of the other, which of course is impossible.

Vertices of your quad: q0, q1, q2, q3
Edges that share a vertex: v0 = (q1 - q0), v1 = (q3 - q0)
Point inside the quad: p = s * v0 + t * v1 for some s,t in [0,1]

First glance this looks like one equation with two unknowns, but keep in mind that p, v0, v1 are vectors while s,t are scalars, so in fact you have three equations for the two unknowns (one equation in each of x, y, z). If you write this as a system of three equations you can apply the usual shuffling around, solve for one unknown and insert into the other equation to solve this.