您当前的位置: 首页 > 

FPGA硅农

暂无认证

  • 0浏览

    0关注

    282博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

角和矩形的交点

FPGA硅农 发布时间:2020-07-29 20:40:57 ,浏览量:0

import math
from shapely.geometry import Polygon
import geopandas as gpd

import matplotlib.pyplot as plt


def calc_theta(point1, point2):
    delta_x = point2[0] - point1[0]
    delta_y = point2[1] - point1[1]
    if delta_x > 0:  # 第一第四象限,直接用反正切函数
        return math.atan(delta_y / delta_x)
    elif delta_x == 0 and delta_y > 0:
        return math.pi / 2
    elif delta_x == 0 and delta_y = 0:
        return math.atan(delta_y / delta_x) + math.pi
    else:
        return math.atan(delta_y / delta_x) - math.pi


def calc_cross(bbox, center, theta1, theta2):
    [xmin, ymin, xmax, ymax] = bbox
    [x, y] = center
    up_right_theta = calc_theta(center, [xmax, ymax])
    up_left_theta = calc_theta(center, [xmin, ymax])
    down_right_theta = calc_theta(center, [xmax, ymin])
    down_left_theta = calc_theta(center, [xmin, ymin])
    # 第一个交点
    if down_right_theta             
关注
打赏
1658642721
查看更多评论
0.0392s