SU 7.1.6 Geom::BoundingBox.intersect does not return empty
-
Using SketchUp 7.1.6xxx I am noticing the following behavior (ran on both a PC and Mac):
- Drew 2 components A, and B 2x4x10 each, and positioned them so that once face of each component is 'merged' (sharing exact space) with the other:
I ran the code:
IntersectBounds = CompA.bounds.intersect(CompB.bounds)
which results in a bounding box which is 4 wide x 10 high x 0 deep - so far so good.
- I moved compB backwards along the green axis:
I ran the same code:
IntersectBounds = CompA.bounds.intersect(CompB.bounds)
Logic says that I should get an empty IntersectBounds, but to my surprise- I got the same result as in step 1. a bounding box which is 4 wide x 10 high x 0 deep.
The only way I'd get an empty Geom::BoundingBox object is if the 2 Components do not share any X, Y, or Z spacial space at all (no parallel lines to the axis that go through both components)
Any thoughts? any dev watching these forums?
-
Interesting, this just came up a couple of weeks also. I do not remember what the outcode of that thread was. I'll see if I can find it. Maybe there is some insight to be gained there (and maybe not).
Chris
-
Wouldn't you expect the intital intersection to be 4 x 10, and not 2 x 10?
-
@chris fullmer said:
I'll see if I can find it. Maybe there is some insight to be gained there (and maybe not).
Chris
Thanks Chris!
for what it's worth, I have a workaround for my functions, but just thought I'd post this as this would be a faster and more extensive function to use if it works properly.
@jim said:
Wouldn't you expect the intital intersection to be 4 x 10, and not 2 x 10?
Jim - you are correct. my bad = typo it IS 4x10x0
Sharon.
-
Well, for what its worth, here is the thread that was recently active about a similar (or identical?) issue. I don't know if it helps at all.
http://forums.sketchucation.com/viewtopic.php?f=180&t=28709
Chris
-
Another thing might be a confusion of terms. A Bounding Box method "width" is along the X axis, "height" along the Y, and "depth" the Z.
I haven't ever tried to use this .intersect method, but maybe it's just poorly named. What if you think of it in terms of "overlap"? What it appears to do is give you the length of overlap of the BB's projected infinitely along the Axes. Hopefully the model will explain better.
From this, you can say that if any of the BB dimensions are 0, then the entities do not intersect in 3 dimensions. Or the number of non-zero dimensions equals the number of dimensions that overlap. Maybe - I'm just making this up as I go.
-
I'm not sure if you need this anymore, but here is a method that should only return the intersected bounds:
def intersect(boundingBox1,boundingBox2) newBoundingBox = Geom;;BoundingBox.new bounds1 = [boundingBox1.min.to_a,boundingBox1.max.to_a] bounds2 = [boundingBox2.min.to_a,boundingBox2.max.to_a] intersectBounds = [[0,0,0],[0,0,0]] validBounds = true (0...3).each do |index| if(bounds1[1][index] <= bounds2[1][index]) intersectBounds[1][index] = bounds1[1][index] else intersectBounds[1][index] = bounds2[1][index] end if(bounds1[0][index] >= bounds2[0][index]) intersectBounds[0][index] = bounds1[0][index] else intersectBounds[0][index] = bounds2[0][index] end if(intersectBounds[0][index] > intersectBounds[1][index]) validBounds = false end end if(validBounds) newBoundingBox.add(intersectBounds) end return newBoundingBox end
It doesn't have any error checking, so you might want to modify it if you use it.
EDIT: Fixed
-
And all of this is making the assumption that none of the instances have been rotated. Well, the methods still work, but the results probably won't match your need.
-
@jim said:
I haven't ever tried to use this .intersect method, but maybe it's just poorly named. What if you think of it in terms of "overlap"? What it appears to do is give you the length of overlap of the BB's projected infinitely along the Axes. Hopefully the model will explain better.
Jim - that is exactly my though - the function acts more as an overlap on the PROJECTIONS of the bounding boxes as opposed to it's literal and more logic meaning of actual intersection of SHARED space.
@cjthompson said:
cjthompson - Thanks. I personally have a workaround for my needs. but though I'd post it here hoping that a dev. can possibly pick up on this and maybe work this through. your solution is nice though!
Chris - this is indeed the same issue
Advertisement