Simple 3D AABB-Line Segment collision detection (intersection)
I just need a method to tell me whether an axis aligned bounding box in 3D intersects a line segment (not a ray) or not. I do not need the points of intersection.
The box is defined by 2 opposite corners, and the line segment by its start and end points, something like this:
Boolean intersection(Vector3 boxStart, Vector3 boxEnd, Vector3 segmentStart, Vector3 segmentEnd){...}
I've done a lot of research, and havent been able to find a code (in C# or Java hopefully) that I can u开发者_如何转开发nderstand or at least use. I need the method and not a library that will do the job...
My problem is that it needs to be 100% precise, and if the segment just touches the box (i.e. they share a single point), it has to return false. For example, if the segment is one of the edges of the box or passes though a corner, they DO NOT intersect.
Thanks
In Java, either of the intersects()
methods is a candidate; but due to implementation limitations, you'd need to test it with Line2D
.
精彩评论