[Python] How to judge if a polygon is inside another polygon in Python?

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I need to define a Python function which can dectect if a convex polygon (polygon a) is inside another polygon(polygon b).

    The vertex of each polygon are given.

    (only use basic lib as well as numpy)

    It’s easy for a human to make a judgement with their eyes. But I have no idea how to describe the method in Python. I have tried to check some source code of lib (like shapely) but can't understand how it works. '''

    def isinside(polya, polyb):
    #Polya: [(x1,y1), (x2,y2), (x3,y3),...]
    #Polyb: [(x1,y1), (x2,y2), (x3,y3),...]
    #if polya inside polyb
    return True
    # else
    return False


    ''' Could someone please give some advice or show some codes? Thanks!

    Continue reading...

Compartilhe esta Página