Lets say that a line consisting of these two points A (108, 157) and B (144, 132) exists and that we are trying to find if another point collides with said line. If I'm understanding this correctly, I would want to create a perpendicular vector from this initial line to the point of interest, calculate the magnitude of this vector, if positive its on side A and if negative its on side B - resulting in collision. Is this correct? If this is not correct (albeit - perhaps even far off) would / could you provide me with a trivial example to demonstrate how the perpDot would be used correctly in this situation?
You got it.
The edges are given in order left to right, and their respective endpoints are also ordered this way. This allows you to determine line segments and write them down as limited ray:
sn( t ) := pn + t * dn , 0 <= t <= 1
dn := pn+1 - pn
where pn denotes your points[n] array element at index n. Notice that using t==0 gives the start point, t==1 gives the end point, and 0<t<1 gives any point in-between.
Now let us use the perpDot to compute a perpendicular vector to d. There are 2 possibilities, and it makes a big difference whether we use the one or the other. We use the ceiling of our room and define that the "positive" side should be below the ceiling. Hence we want the perpendicular vector point more-or-less downwards. So we pick
vn := [ dny, -dnx ]
as the perpendicular vector.
With this we could formulate an equation with which we want to reach the point of interest c (i.e. the one to check for collision):
pn + t * dn + u * vn = c
So the steps to determine on which side the point of interest is w.r.t. to an edge are:
1.) get the 2 points from the array
2.) compute their difference vector d (take care or order)
3.) compute the perpendicular vector v
4.) compute the difference from the edge's start to the point of interest
5.) commute the distance u
6.) assess the distance with 0 as border
Notice that the floor is different, because you want to assess the point of interest to be above it (for the ceiling it was below). You can do so by either use the other perpDot result or else say that an u below 0 means no collision and greater or equal to zero means collision.
(BTW: I've written this down from the top of my head, so please check it thoroughly.)
I also just realized that the link containing the photo image of this scenario isn't able to be used in this thread for some reason. Is it easy enough to understand the action I'm looking for without the visual?
I personally had not imagined your problem correctly before I had a look at the picture. I've investigated the HTML source and found the link by searching the word "apparently". For sure that is not convenient ;)
If you want to put a link in a post then write down the link text, mark it, press the chain symbol in the editor's toolbar, and paste the URL into the opening requester. That should do the trick.