Has anyone had problems with this. This is my first time using it, and I'm using it in conjunction with valid? to see if there are any points.
What I've found is that if my two groups (in this case cubes) don't share any X-axis limits, then it correctly identifies if the objects touch or not. If however they have overlapping X-axis limits, it always returns "true" for BoundingBox.intersect.valid? even if the Y-axis and Z-axis limits don't overlap at all. If any of the three axes don't overlap the valid? should return "false" Below I took the code from the API sample and adjusted it to show two parallel lines that are running along the Y and then the X axis. They should both return false, but the pair along the X axis returns true.
Any thoughts on this?
boundingbox1 = Geom;;BoundingBox.new
boundingbox1.add [0,0,0]
boundingbox1.add [0,100,0]
boundingbox2 = Geom;;BoundingBox.new
boundingbox2.add [100,0,0]
boundingbox2.add [100,100,0]
boundingboxA = boundingbox1.intersect boundingbox2
puts boundingboxA.valid?
boundingbox3 = Geom;;BoundingBox.new
boundingbox3.add [0,0,0]
boundingbox3.add [100,0,0]
boundingbox4 = Geom;;BoundingBox.new
boundingbox4.add [0,100,0]
boundingbox4.add [100,100,0]
boundingboxB = boundingbox3.intersect boundingbox4
puts boundingboxB.valid?
boundingboxA.valid? correctly returns "false"
boundingboxB.valid? incorrectly returns "true"
FYI - I have attached a screenshots of a simple example using two cubes where one returns true and the other false. Code above is similar but just two lines, vs. two boxes.
![This correctly shows boundingbox.intersect? as "false"](/uploads/imported_attachments/EJqD_intersectreturnsfalse.png "This correctly shows boundingbox.intersect? as "false"")
![This incorrectly shows boundingbox.intersect? as "true"](/uploads/imported_attachments/psx5_intersectreturnstrue.png "This incorrectly shows boundingbox.intersect? as "true"")
Just a short followup. If I add the following code to each pair of lines here are the results
puts boundingboxA.diagonal
puts boundingboxA.height
puts boundingboxA.depth
puts boundingboxA.width
puts boundingboxA.corner (0)
puts boundingboxA.corner (1)
puts boundingboxA.corner (2)
puts boundingboxA.corner (3)
puts boundingboxA.corner (4)
puts boundingboxA.corner (5)
puts boundingboxA.corner (6)
puts boundingboxA.corner (7)
8' 4"
8' 4"
0"
0"
(1000000000000000000000000000000", 0", 0")
(-1000000000000000000000000000000", 0", 0")
(1000000000000000000000000000000", 100", 0")
(-1000000000000000000000000000000", 100", 0")
(1000000000000000000000000000000", 0", 0")
(-1000000000000000000000000000000", 0", 0")
(1000000000000000000000000000000", 100", 0")
(-1000000000000000000000000000000", 100", 0")
false
8' 4"
0"
0"
8' 4"
(1000000000000000000000000000000", 0", 0")
(100", 1000000000000000000000000000000", 0")
(0", -1000000000000000000000000000000", 0")
(100", -1000000000000000000000000000000", 0")
(0", 1000000000000000000000000000000", 0")
(100", 1000000000000000000000000000000", 0")
(0", -1000000000000000000000000000000", 0")
(100", -1000000000000000000000000000000", 0")
true
""