# Bounding Box Intersection Speed

What is the relative speed difference between the various intersection nodes? I’ve been assuming that bounding box clash is faster than DoesIntersect which is definitely faster than a straight geometry intersection. Correct? If so, any thoughts as to how much difference between them?

That sounds right. And it’s logical too.

Bounding boxes are defined by two points. If point 1 or point 2 is greater than the min point, and less than the max point, they intersect. You could do the math for that by hand in a minute or so.

Geometry.DoesIntersect is slower as dynamo has to build up the geometry first, and then attempts to test each part of geometry A against each part of geometry b. That is each face, solid, etc is tested against the other, as geometries aren’t necessarily single pieces. If they intersect than it returns true and nothing more happens. If they don’t it returns false and nothing more happens. It’s conceivable that a complex geometry could be tested mathematically by hand.

Geometry.Intersect is slowest as it takes the does Intersect node a step further. After testing, it calculates the intersecting form, which is again doing the math to make three sets of geometry after testing for the intersecting parts… I have yet to meet someone who could do that math by hand in a reasonable timeframe for anything more complex than basic primitives.

Yeah, that’s about what I thought.

In that case, what’s the math for the bounding box calculations? I know we can’t, yet, create an object aligned bounding box (which is what I’d like) but I can surely get the 6 points (really 4 in my case since I’m getting the BB of a surface) of what might be the extents of a volume surrounding the element and use these points in a set of manual calculations.

I’m not a math or geometric form wizard

For a rotated “bounding box” you would need 8 points - 4 for the top and 4 for the bottom. This wouldn’t be a bounding box though - think of it as actual geometry simulating a bounding box.

The real advantage of the bounding box is that they are defined by only the two points, whereas the rotated “bounding box” requires 8, so 4x the amount of calculation power just to make them.

Intersection tests are worse. Intersection tests on 2 points x 2 points is 4 tests. Intersection tests on 8 points by 8 points is 64 tests.

I think it would be possible to create a bounding box by a coordinate system without too much work beyond figuring the coordinate system. A problem for another day though.