sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    SU 7.1.6 Geom::BoundingBox.intersect does not return empty

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 4 Posters 876 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      PurpLev
      last edited by PurpLev

      Using SketchUp 7.1.6xxx I am noticing the following behavior (ran on both a PC and Mac):

      1. 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:

      http://lh6.ggpht.com/_I0z5c0MXdBw/TCD3Stx7L2I/AAAAAAAAAA0/tltkniuj58w/Picture 3.png

      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.

      1. I moved compB backwards along the green axis:

      http://lh3.ggpht.com/_I0z5c0MXdBw/TCD3S9gHozI/AAAAAAAAAA4/4tpkXRQg_Ko/Picture 4.png

      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?

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        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

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          Wouldn't you expect the intital intersection to be 4 x 10, and not 2 x 10?

          Hi

          1 Reply Last reply Reply Quote 0
          • P Offline
            PurpLev
            last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              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

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                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.

                428.png

                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. πŸ˜„


                bb_intersect.skp

                Hi

                1 Reply Last reply Reply Quote 0
                • C Offline
                  cjthompson
                  last edited by

                  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

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jim
                    last edited by

                    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.

                    Hi

                    1 Reply Last reply Reply Quote 0
                    • P Offline
                      PurpLev
                      last edited by

                      @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

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement