过线检测时需要判断目标是从哪个方向经过的
L1向量:(-1,-7)
L2向量:(-5,0)
叉乘:L1 X L2 = (-1x0 - (-5 x -7)) = 0 - 35 = -35
点乘:L1 · L2 = -1 x -5 + -7 x 0 = 5
arctan(-35/5) = -81.87
因为y = -35 ,x = 5
所以atan2(-35,5) = arctan(-35/5) = -81.87
L1向量:(-1,-7)
L2向量:(5,0)
叉乘:L1 X L2 = -1 x 0 - (5 x -7) = 35
点乘:L1 · L2 = -1 x 5 + -7 x 0 = -5
arctan(-35/5) = 81.87
因为y = 35 ,x = -5
所以atan2(35,-5) = arctan(-35/5) = -81.87 + Π = 98.13
因此可以用这种角度正负判断目标运动方向