Intersection and Bounding box

Intersection and Bounding box

Anonymous
Not applicable
2,131 Views
6 Replies
Message 1 of 7

Intersection and Bounding box

Anonymous
Not applicable

In our application we are using a closed polyline in the form of rectangles to detect objects that may be enclosed within the rectangle.  In addition to enclose, we also want to detect intersection with the polyline using other objects.  We are using the function Obj.BoundingBoxIntersectWith(2ndObj, Intersect.ExtendBoth, intersectionPts, new IntPtr(0), new IntPtr(0)); to accomplish this goal, but there seems to be issues with the function picking up objects outside of the closed polyline.  Any ideas what could cause this issue?  Is there a better to detect objects within a closed polyline?

0 Likes
2,132 Views
6 Replies
Replies (6)
Message 2 of 7

ActivistInvestor
Mentor
Mentor

@Anonymous wrote:

In our application we are using a closed polyline in the form of rectangles to detect objects that may be enclosed within the rectangle.  In addition to enclose, we also want to detect intersection with the polyline using other objects.  We are using the function Obj.BoundingBoxIntersectWith(2ndObj, Intersect.ExtendBoth, intersectionPts, new IntPtr(0), new IntPtr(0)); to accomplish this goal, but there seems to be issues with the function picking up objects outside of the closed polyline.  Any ideas what could cause this issue?  Is there a better to detect objects within a closed polyline?


The bounding boxes of two objects can intersect even if the objects themselves don't actually intersect.  Is that what you mean?  

 

Bounding box intersection is typically used for trivial-rejection of potential candidates. IOW, if the bounding boxes of two objects do not intersect, then the two objects do not intersect either. So, you can use BoundingBoxIntersectWith() to more-efficiently disqualify objects before resorting to more expensive computations (such as IntersectWith).

 

So, your process might first use BoundingBoxIntersectWith() on two objects, and if there is no intersection, you can assume the two objects don't intersect. Otherwise, you would then use IntersectWith() to compute the actual intersections..

Message 3 of 7

BKSpurgeon
Collaborator
Collaborator

My suggest it to make sure you are using the correct Intersect enumeration. My understanding of the: Intersect.ExtendBoth enumeration is that, if a line that is outside the box is extended, then it will be picked up as an intersection if it intersects with the bounding box. There are other enumerations, choose the: Intersect.OnBothOperands enumeration and it will only pick up direct intersections with the boudning box: 

 

try this:

 

Obj.BoundingBoxIntersectWith(2ndObj, Intersect.OnBothOperands, intersectionPts, new IntPtr(0), new IntPtr(0));
0 Likes
Message 4 of 7

ActivistInvestor
Mentor
Mentor

@Anonymous wrote:

 

  ...Obj.BoundingBoxIntersectWith(2ndObj, Intersect.ExtendBoth, intersectionPts, new IntPtr(0), new IntPtr(0))...


Sorry, I didn't notice that you were using Intersect.ExtendBoth, as @BKSpurgeon rightly pointed out, and that makes a big difference.

 

You should use Intersect.OnBothOperands for that argument.

0 Likes
Message 5 of 7

Anonymous
Not applicable

Is there a way to prevent an extended line outside the bounding box from pick up as an intersection while using the Intersect.ExtendBoth argument?

0 Likes
Message 6 of 7

ActivistInvestor
Mentor
Mentor

@Anonymous wrote:

Is there a way to prevent an extended line outside the bounding box from pick up as an intersection while using the Intersect.ExtendBoth argument?


No, I don't believe there is.

0 Likes
Message 7 of 7

BKSpurgeon
Collaborator
Collaborator

extendWithBoth.png

0 Likes