i*******D 发帖数: 993 | 1 我想判断3d空间中一个线段和在一个点的关系. 这个点在这个线段的直线上,我想判断
它在线段的两个端点之间还是在之外. 这个问题本身是一个明确的判断,不能容忍error
和tolerance.
比如线段是AB, 另外一个点是C. 我的方法是判断if AB-(AC+BC)<0. 但是在实际运算中
,我发现即便是C在AB之间,也有很多时候AB-(AC+BC)<0. 应该是因为round off error.
不知道有什么好的trick或者策略来解决这个问题. | k**********g 发帖数: 989 | 2 If it is given beyond doubt that C is a point on the line extension of AB,
then C is outside the finite segment AB iff
C is outside the axis-aligned bounding box
the cartesian product with
( all x in (xmin, xmax) ) and
( all y in (ymin, ymax) )
where xmin = min ( A_x , B_x )
xmax = max ( A_x , B_x )
etc etc.
for 3D, 4D etc just apply cartesian product over all dimensions.
Upon thinking about that, it seems that even if you apply a unitary
coordinate transform (unitary rotation and/or mirroring) the "iff" still
holds. Not very sure, but seems interesting.
Not a proof.. just a sketch of idea. No guarantee. If there is a mistake
please leave a comment. Thanks. | i*******D 发帖数: 993 | 3 我想判断3d空间中一个线段和在一个点的关系. 这个点在这个线段的直线上,我想判断
它在线段的两个端点之间还是在之外. 这个问题本身是一个明确的判断,不能容忍error
和tolerance.
比如线段是AB, 另外一个点是C. 我的方法是判断if AB-(AC+BC)<0. 但是在实际运算中
,我发现即便是C在AB之间,也有很多时候AB-(AC+BC)<0. 应该是因为round off error.
不知道有什么好的trick或者策略来解决这个问题. | k**********g 发帖数: 989 | 4 If it is given beyond doubt that C is a point on the line extension of AB,
then C is outside the finite segment AB iff
C is outside the axis-aligned bounding box
the cartesian product with
( all x in (xmin, xmax) ) and
( all y in (ymin, ymax) )
where xmin = min ( A_x , B_x )
xmax = max ( A_x , B_x )
etc etc.
for 3D, 4D etc just apply cartesian product over all dimensions.
Upon thinking about that, it seems that even if you apply a unitary
coordinate transform (unitary rotation and/or mirroring) the "iff" still
holds. Not very sure, but seems interesting.
Not a proof.. just a sketch of idea. No guarantee. If there is a mistake
please leave a comment. Thanks. |
|