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
查看更多评论