射线与射线的交点计算
p0,v0
p1,v1
if v1.x * v0.y == v0.x * v1.y
# 两条射线平行 无交点
else
t0 = ((p0.x - p1.x) * v1.y - (p0.y - p1.y) * v1.x) / (v1.x * v0.y - v0.x * v1.y)
t1 = ((p0.x - p1.x) * v0.y - (p0.y - p1.y) * v0.x) / (v1.x * v0.y - v0.x * v1.y)
if t0 <= Fix16(0) or t1 <= Fix16(0)
# 交点不在两射线方向,不相交
else
p = p0.x + v0.x * t0 , p0.y + v0.y * t0
网友评论