如何解决检查点是否在旋转矩形内
我正在尝试检查一个点是否在旋转的矩形内。 我发现:https://gamedev.stackexchange.com/questions/128598/collision-detection-point-hitting-a-rotating-rectangle
但它不起作用... 这是我的python代码:
def collides(point_x,point_y,x_rect,y_rect,width_rect,height_rect,center_rect_x,center_rect_y,angle_rect):
radians = angle_rect / 180.0 * math.pi
angle_sin = math.sin(radians)
angle_cos = math.cos(radians)
x = ((point_x - center_rect_x) * angle_cos - (point_y - center_rect_y) * angle_sin) + center _rect_x
y = ((point_x - center_rect_x) * angle_sin + (point_y - center_rect_y) * angle_cos) + center_rect_y
return x > x_rect and x < x_rect + width_rect and y > y_rect and y < y_rect + height_rect
如何检查点是否与旋转的矩形碰撞?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。