Anyone know where I can get an implementation of this? Some code to read in a set of vertices/triangles and then do some simple intersection tests? If you can point me in the right direction that'd be great!

Thanks,

Dave

daviddoria
334
Posting Virtuoso
Featured Poster

Anyone know where I can get an implementation of this? Some code to read in a set of vertices/triangles and then do some simple intersection tests? If you can point me in the right direction that'd be great!

Thanks,

Dave

Jump to PostAnyone know where I can get an implementation of this? Some code to read in a set of vertices/triangles and then do some simple intersection tests? If you can point me in the right direction that'd be great!

Thanks,

Dave

Seems like you can easily do this by emulating a …

Jump to PostActually, i just found a better solution.

If at any given time, a point from the outside of the triangle has a shorter distance than all of the shortest distances from points to their opposite sides, then there is obviously an intersection.

If even one of those points …

Alex Edwards
321
Posting Shark

Thanks,

Dave

Seems like you can easily do this by emulating a Cartesian plane and then finding out if the arc-tangent of the coordinates a triangle on its own separate axis is greater than, less than or equal to the other triangle in question.

If the initial triangle has a smaller arc-tan than the other triangle and a point of the other triangle is found within the "square" bounds of the initial triangle then an intersection has occurred, otherwise there is no intersection.

You'd have to cycle through the possible vector collisions of one triangle to the other, but the idea is pretty straightforward.

Alex Edwards
321
Posting Shark

Actually, i just found a better solution.

If at any given time, a point from the outside of the triangle has a shorter distance than all of the shortest distances from points to their opposite sides, then there is obviously an intersection.

If even one of those points return a longer distance than the shortest distance to the opposite side when taking the difference of the point in question, then no intersection has occurred.

daviddoria
334
Posting Virtuoso
Featured Poster

Alex Edwards
321
Posting Shark

You know, the funny thing is that when you mentioned this I worked on it right away since it seemed like an interesting project.

I have a program that creates triangles on a particular location in the imaginary Cartesian plane and can detect collisions using an equals assignment, however I'm still trying to figure out the accuracy of the collision-detecting operation.

So far it seems very accurate but more testing needs to be done.

vijayan121
1,152
Posting Virtuoso

many people have. google for Moller-Trumbore algorithm.

two other implementations:

http://jgt.akpeters.com/papers/Chirkov05/C2005.cpp.html (chirkov's c2005 algorithm)

http://geometryalgorithms.com/Archive/algorithm_0105/algorithm_0105.htm#intersect_RayTriangle() (sunday)

daviddoria
334
Posting Virtuoso
Featured Poster

ok folks, i couldn't find anything that wasn't crazy overly complicated, so I wrote it myself:

http://doriad.myrpi.org/ObjReader.cpp

The triangle intersection is a bit harder to post because it uses a big geometry library that I have written, but I'll post the main intersection function once I test it.

Dave

Alex Edwards
321
Posting Shark

ok folks, i couldn't find anything that wasn't crazy overly complicated, so I wrote it myself:

http://doriad.myrpi.org/ObjReader.cppThe triangle intersection is a bit harder to post because it uses a big geometry library that I have written, but I'll post the main intersection function once I test it.

Dave

I've actually come up with a formula to solve for all intersections, however it's harder to implement than I thought.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.