sverchok icon indicating copy to clipboard operation
sverchok copied to clipboard

Distance Line Line wrong result

Open ArpegorPSGH opened this issue 2 years ago • 5 comments

When applying this node to parrallel lines, intersection flag is True instead of False (the distance between lines is far greater than Tolerance). Could this be corrected?

ArpegorPSGH avatar Apr 08 '22 09:04 ArpegorPSGH

it's behaving as intended, according to the code that implements that function.

 In case of parallel lines it will return the origin of the first line as the closest point 

https://github.com/nortikin/sverchok/blob/675f70c33f537c87f546e35a8394fe63960dec44/utils/geom.py#L2479-L2510

zeffii avatar Apr 09 '22 12:04 zeffii

i think your suggestion is valid.

zeffii avatar Apr 09 '22 12:04 zeffii

when the else is run, the dist = (inter_p[0] - line_origin_b).length part is (i think) likely (but depending on the orientation of the lines) to be an operation on the same vector3d. there inter_p[0] and line_origin_b are identical, and subtracting one from the other will result in a (0, 0, 0) and have 0 length

zeffii avatar Apr 10 '22 15:04 zeffii

One solution is to calculate the angle between the line's directions and if it is 0 or 180, output false for intersection.

ArpegorPSGH avatar Apr 11 '22 08:04 ArpegorPSGH

Well, after analysing it a bit, the problem just stems from a little mistake from the author of the function : instead of dist = (inter_p[0] - line_origin_b).length, it should be dist = (inter_p[0] - line_origin_a).length. Perhaps you could correct that, @zeffii.

ArpegorPSGH avatar Aug 14 '22 15:08 ArpegorPSGH