i would like to know if a point in a plane segment, and its coordinate in [0,1][0,1] relative to segment. e.g 0,0 left bottom corner, 1,1 right top corner, 0.5,0.5 center
these are the thing i already know:
-point is in on the same plane as plane segment.
-coordinates of 4 points of the plane segment. but they are not clock-wise order or any order i would know.
-plane’s normal and its distance to origin. such as; ax + by + cz +d . x,y,z,d are known.
A,B,C points are on same plane as plane segment. P1, P2, P3, P4 coordinates is known, but is not ordered in any meaningful way.
thank you.
edit:
one idea i have is
-
sort points
-
create vector between each points
-
create vectors from 2 points
-
dot product them
-
if degree is between 0 and 90, it’s inside
would this work? i need good real-time performance, isn’t dot product is slow on CPU?
how would i find relative coordinate of point?

In my opinion the best way to check this is transforming the whole plane and the points to the origin of coordinate system: Translate every point so the left bottom point will be in the center of coordinate system, and rotate everything so the normal vector will be pointing parallel with one of the axes. This means a matrix multiplication for every point, but after this you can easily check which points are in the rectangle. This is an XNA C# implementation, but the logic is the same everywhere: (I tried to use your sketch for inputs)
This works on any four points.
It’s not the fastest solution, but I’m sure it’s the cleanest and simplest if you know matrix transformations. If you find any faster and yet simple solution I’m interested too, but probably there will be no performance issues. On my Intel 2.4ghz processor this computation happens more than 1 million times under 1 second without any problem. Hope this helps, good luck!