Method to find out if edges of polygons touch?

Hi!!

I am building an experiment in psychopy (v2021.1.4) in which I have a polygon (oval) inside another (trapezoid) as seen in picture.

The trapezoid’s vertices gradually reduce in shape one at a time, and I’d like to find out if any of the edges of the trapezoid ever cross the boundary of the oval.

>
>

My final aim is to prevent the trapezoid’s edges from ever touching the oval’s boundaries. I have tried using overlaps(polygon) but it always returns TRUE because one of the polygons is inside the other. Does anyone know if there’s a similar function that only accounts for the edges of the polygon?

Thanks a lot in advance!!!

There’s no existing function but I can think of a way of using overlap to do this: Remake your trapezoid as four independent visual.Line objects. Since you’re deforming the trapezoid, your shape is probably already a set of four vertices that are being updated, so you just need to make those vertices the start- and end-points of four different lines instead of a single object. Then you can check if any of the line objects overlap with the circle and it won’t take into account the interior space between them.

Hi Johanthan!!! Edit to my response, I tried using lines for the overlaps function:

But I get the following error when I do so:

“ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 120 and the array at index 1 has size 129”

Do you have any idea of why?? Couldn’t find anything online!!

Thanks in advance:)

Fixed the error by creating a rectangle made out of 2d ShapeStim stimuli that look like lines, such as: