Sorting according to clockwise point coordinates

前端 未结 7 2202
别跟我提以往
别跟我提以往 2020-12-16 18:18

Given a list in Python containing 8 x, y coordinate values (all positive) of 4 points as [x1, x2, x3, x4, y1, y2, y3, y4] ((xi, yi) are x and y coo

7条回答
  •  渐次进展
    2020-12-16 18:42

    # P4=8,10 P1=3,5   P2=8,5   P3=3,10
    points=[8,3,8,3,10,5,5,10]
    k=0
    #we know these numbers are extreme and data won't be bigger than these
    xmin=1000
    xmax=-1000
    ymin=1000
    ymax=-1000
    #finding min and max values of x and y
    for i in points:
        if  k<4:
            if (xmin>i): xmin=i
            if (xmaxi): ymin=i
            if (ymax

    output:[3, 3, 8, 8, 5, 10, 10, 5] for other regions you need to change sortedlist line. if center is inside the box then it will require more condition controlling

提交回复
热议问题