I’m trying to figure out if there’s a way to get the x and y coordinates of where two separate shapes (any shapes) touch. Any idea how I might obtain that information?
You can go have a look there: http://jeffreythompson.org/collision-detection/poly-poly.php
maybe I’m mistaken, but it looks like the method you attached only tells me if two separate shapes touch, in the form of a boolean. I need to know precisely where they touch.
It is indeed not directly mentioned but the idea is here.
What you want to do is to check each segment of the first poly to each segment of the second poly.
For every segment you compute the slope and the origine coordinate. At that step you have to equation one for each segment y = a1 x + b1 and y = a2 x + b1.
You first check that they are not parallel (a1 = a2). If that’s the case either b1 = b2 and the intersection point is actually a segment or nothing. Either b1 <> b2 and there is no intersection point
If they are not parallel, the intersection point of the 2 lines (and not segment) can be found by solving the system a1 x + b1 = a2 x + b2 to find x and replace this x value in any of the 2 line equations to get the y.
Last step is to check if the point belong to the segments by checking for example if the x is between xlin and xmax if either of the 2 segments.
That’s one obvious way to do it but you could also paramétrée your segment with a variable t going from 0 to 1 as a percentage of the segment (meaning t = 0 gives you the first point of the segment up to t = 1 sliding to the lst point of the segment). In this case you solve for t and simply check that it is between 0 and 1 to check if the intersection point is within the segments.