Reputation: 2210
I was looking for any C++ library which allows me to get the 3D point of collision between a line and a Polyhedron/sphere (where the line consist of two 3D points and the polyhedron of a finite amount of 3D points)
As to my surprise I cannot seem to find such a library (or I don't know which phrases to search for).
Also, most collision libraries I have seen are from 2005/2006 (but none saying how to get the hit point coordinates, most of them are for visualising things and checking boundaries, or collisions between two 3d objects, etc. Too overkill for me - I just want the 3D point of collision between a line and a 3D object [polyhedron / sphere] )
So.. which libraries are up-to-date as of 2013 and utilize the new techologies to achieve the best performance?
Or is there a code sample for my case?
I sometimes like reinventing the wheel but not in this case, I would like it to use it for a plugin for a game - so something that is reliable and fast is preffered.
Upvotes: 1
Views: 1102
Reputation: 22308
What's fast and efficient depends on how many objects there are, etc. There's not much point building an octree or some other spatial partition if you're only going to test a few objects. You might consider trying to find the (bounding) sphere (origin + radius) that encloses the polyhedron, and test to see if that is intersected first. Or an axis-aligned bounding box (AABB).
Then you can move onto the more expensive polyhedral test - which might require testing against each 'front-facing' triangle. Then there are issues if the object is not convex, like a mesh, in which case you need the ray of least distance.
see: CGAL, Geometric Tools.
Upvotes: 3
Reputation: 380
Have you checked out http://clb.demon.fi/MathGeoLib/nightly/usermanual.html#features
This seems like a duplicate of Set of efficient 3D intersection algorithms
Upvotes: 1