# Line intersection

patched a line intersection node (ray intersect ray and distance)
and a line adder (that checks new items for intersection with existing ones)
not sure how to arrange them in one region

line intersection.vl (78.5 KB)

you have to move the pad out of the region. pads just work within their “context”, so the region is its own context. Now ALL your lines are intersecting because you check each line for collilsion with itself. And I think you should not normalize the ray, because you then loose its length information. normalizing resizes the vector to length 1

you have to move the pad out of the region

like this ? neither did work

pads just work within their “context”, so the region is its own context

Now ALL your lines are intersecting because you check each line for collilsion with itself

was not expecting self-intersectiong as test for collision is upstream from add to pad

And I think you should not normalize the ray

reason for nomalize is that ray(join) requires position and direction
a test of the intersection algorythm is running near the renderer part
line intersection 1.vl (81.1 KB)

your pad use is fine. Just be aware that pads just connect if the are both within or outside a region. It can be tricky when the pad is actually “outside” the region, but then moved “behind” it like in the picture above.

if you check your object against the whole spread of objects it also checks against itself. use some id or the index of the loops to create a condition that does not check if the current line and line to check are the same.

The ray is infinite if it just has position and direction imo. So be aware that this can create multiple hits you don’t really want. I’m not the ray expert here but I believe that is how they work. correct me if I’m wrong.

The ray is infinite if it just has position and direction imo. So be aware that this can create multiple hits you don’t really want. I’m not the ray expert here but I believe that is how they work.

sollution against multiple hits is to limit to the cases where
d(pointA, intersectionpoint)+d(pointB, intersectionpoint)=d(pointA,pointB)

problem is, in the consecutive scenario, they touch eachother

Are you experimenting or do you have a concrete use case? I believe gamma has no implementation to do line intersections out of the box. If you need exactly that I think you have to implement that functionality yourself, and I can’t really help with that.

Just be aware to do anything to make the algorithm more efficient. For example make bounding boxes for each line and first check which lines actually are able to cross each other before you try to find the exact point.

You could also search for a nuget which offers that kind of functionality.

thank you for the notes,
was trying to figure definitions mostly,
now the patch works as a stable polyline grower that won’t overlap itself
walker 4.vl (71.2 KB)

Don’t know if you’re still after that, but the source files from the Using .NET Nuggets workshop from NODE20 has an example on how to check if a point intersects a line :

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.