prochitecture / blosm

GNU General Public License v3.0
9 stars 3 forks source link

A code for the intersection point of 2 line segments #99

Open vvoovv opened 1 month ago

vvoovv commented 1 month ago

I am starting to implement intersections with Geometry Nodes. For that I will need to find an intersection point of 2 line segments.

Where can I find the code for that in the existing code base of the addon?

polarkernel commented 1 month ago

Where can I find the code for that in the existing code base of the addon?

For instance, the function _isectSegSeg() does that, see line 116 in lib/CompGeom/BoolPolyOps.py.

vvoovv commented 1 week ago

There is a condition in the function _isectSegSeg()

if 0. < t1 < 1. and 0. < t2 < 1:

Why doesn't it include 0 and 1?

vvoovv commented 1 week ago

In other words, why doesn't it have the form

if 0. <= t1 <= 1. and 0. <= t2 <= 1:

?

polarkernel commented 1 week ago

In other words, why doesn't it have the form if 0. <= t1 <= 1. and 0. <= t2 <= 1: ?

_isectSegSeg() is used by the function 'boolPolyOp()', which finds unions, intersections and differences of polygons. It finds the intersection points of the polygons. The endpoints of the polygon segments are already processed as IN, ON or OUT of the partner polygon, before these intersections are calculated. Since these endpoints are already known, they must be excluded by _isectSegSeg(), so that they are not duplicated. Therefore, 0 and 1 are excluded.