Region of intersection of ofPolyline's

I’m trying to find the intersecting region of two ofPolylines. Specifically, one ofPolyline is a pose mask and the other is a contour from TSPS. My visual goal is to simply visualize the intersection. My current approach is too slow, was curious if anyone had any suggestions!

Current approach:

ofPolyline p1, p2
Find bounding boxes: b1 and b2

For each pixel in intersection(b1, b2):
---- if p1.inside(pixel) and p2.inisde(pixel):
---- ---- draw(pixel)

if you want to get the geometric intersection of polygons I’d use this add-on:

another option which might require some effort (but be relatively low cost) is to render both polygons into images and look at the intersection (&&) of images. I would do this by rendering both polygons to two fbos, render those fbos into another with a shader that does the &&, then read back that FBO to pixels for a faster version of what you are doing above with checking each pixel…

2 Likes

Worked like a charm, thanks!