Is shape 1 totally inside shape 2?

What do you think the best way for working out if shape 1 is totally inside shape 2?

If we compare the green shape( shape 1) to shapes A, B and C (shape 2)

image

I’m thinking I need to use a combination of points and surfaces.

I tried it with corner point of black rectangles inside green surface but it fails in this scenario:
image

Thoughts anyone?

hi, with volumes:
V1 volume V1
V2 to check if inside V1
Boolean operation Vdiff = V1-V2

Vdiff + V2 ==V1

cordially
christian.stan

1 Like

So… subtract surfaces and get the area of the resultant surface then check that against what it should be?

1 Like

Draw a very long line from one of the vertices and collect the intersections with the green line. If the number of intersections is an odd number, it is inside. 0 or even intersection points, means outside.

1 Like

Doesn’t work for my second image though?

All the vertices are inside, but the shape isn’t.

probably i total misunderstanding :wink: as usual :wink: but is something here…

Revit_GztI1yX6Lu

1 Like

Normally you check first if two shapes intersect, if not then check if it is totally inside.

If they have elevations, you need to temporary create objects without elevation of course.

Am just using 2D shapes (floor plan)

Uhm, never mind. There is also a Containment Test node, so after the intersection you can check for one vertice to be inside the polygon of the other object.

1 Like

As with my second image, even if all the vertices are inside the big green polygon, part of the shape (black rectangle) could still be outside.

Yes, therefore your first check is if the forms intersect.If not, then you check if it is inside.

2 Likes

Intersect Shape1 with Shape2. If the intersection has the same area as the original Shape1, then it’s fully inside Shape2.

5 Likes

Ooo, loving this one :smiley:

FYI: The containment test node is slower than patching the larger surface and checking to see if the point intersects the surface with a Geometry.DoesIntersect node. Why? I don’t know… but if you sequentially add points to the base polygon you’re checking for containment with you can start to see the impact on speed.

2 Likes

Beyond the area test which can have issues with floating point comparison, you can take the difference of the object and the container; if the resulting surface has a “NO FACES IN BODY” error you are entirely enclosed.

4 Likes

I shall add a tolerance :slight_smile:

Thanks all… love all the ideas.

Going to go play with them now.

@Nick_Boyts method done in Dynamo and then in Dyno + Python. Works beautifully with the added tolerance.

1 Like

hi, very nice


cordially
christian.stan

1 Like

I’ve had almost a full week to mess about with Dynamo (no deadlines). It’s been epic :smiley:

Function Compose with Surface.Difference (and the larger surface plugged into the other input) and an IsNull’ node as the two functions then connected to a Function Apply` node would help prevent the warning.

1 Like