# About shapes (inside, out, intersections points)

Hi there :)

I’m building a simple drawing interface, for the moment I just created a way to draw shapes :

by pressing the left button I draw points in the renderer, then connect them (with the connect node) and draw lines from these connection.

I have two question about created shapes :

• Is it possible to detect if a shapes is drew inside or
outside another (or both) ?

• also, is it possible to detect intersection points between 2 shapes ?
In fact, I’ve found out the topic about detection of intersection point between 2 straight lines, but here it isn’t straight lines but shapes visually made of segment (and not vectors) so when I try the 2LineIntersectionPoint node, it return lots of point outside of shapes (cause it find intersection of vectors)
So a way should be to convert line output into points (and then compare all points form both of the shapes to find same points) but I didn’t find out how to do that .

so Does anyone know how to convert line into point (with their values) ?

If somebody has an idea, please tell me ^^

• Is it possible to detect if a shapes is drew inside or
outside another (or both) ?

That shouldnt be a big issue - just check if Xy-values are smaller or bigger than the other. Before it, I would specify my shape (think you are going to handle a lot of shape, not only two), so use bounds.node for it, to get a rough shape outer dimensions. (give its values into a quad to see it visually)
Check this by vector intersections, to get a selection to be checked in detail:
Now, you should know if your shape is inside, outside or intersecting the second. By this, you can look for a precise check (< or >) for every single XY-pos compared to the second shape.

• also, is it possible to detect intersection points between 2 shapes ?
I guess with the detailed check up, you also can get an intersection. If there are following values giving you first inside AND later outside than you’ve got an intersection. Your node of choice is shift here. By shifting it for one slice (1/amount of slice) you can check both easily with AND node (having first spread < check up and second spread a > check - connect its boolaen outputs to AND).

You get the location of it by putting your boolean 0,1 output of AND into a select node (upper right pin) take lower right pin to get your slice position.

sorry no time for bulding up sample patch.

Hi !

so after some hours on it, I didn’t manage to do it (I think I didn’t totally understand what you explained to me)
in fact I didn’t managed to get intersection of shapes from intersections from their bounds rectangle.

So if you want to have a look at my patch, here it is (the intersectionnode is a subpatch I found it here, but I repost it also for more convenience, just replace URL in node)

So I’m still trying to get intersection point between shapes (and sorry for the messiness of my patch I’ll clean it soon :) )

Thanks a lot for any help ^^

scratch.v4p (89.0 kB)
2LinesIntersectionPoint.v4p (26.6 kB)