IoU
IoU copied to clipboard
is there a logic error in Line::isOnEdge() function?
in iou.cpp line27-29,it is said: if (abs(pp1^pp2) < EPS && pp1pp2 < EPS) return true; which from my point of view is |pp1||pp2|sin(pp1,pp2)<EPS and |pp1||pp2|*cos(pp1,pp2)<EPS. but it doesnt mean that p is on p1p2.
why dont you use the value of cos/sin of pp1 and pp2 to judge if p in on line p1p2?
简单解释一下:
这个接口是判断点是否在线段上
-
abs(pp1^pp2) < EPS(即sin(pp1,pp2)<EPS)说明点P、P1、P2共线(EPS为容差值) - 满足1)的条件下还存在三种可能
a.
P在P1P2线段上(P1_P_P2为180度) b.P在P1P2线段的延长线上(P1_P_P2为0度) c.P在一个相对很远的位置(P1_P_P2为0度,类似于b,算是一种退化?) - 通过
pp1pp2 < EPS排除情况b)和c)
应该是等效于你提到的sin/cos,对2)中不满足的情况无法排除,而且存在除零的风险
我的方法存在归一化的问题,建议对PP1和PP2进行一下归一化