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

Recommended Answers

All 7 Replies

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

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.

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.

Right, but I was wondering if anyone has this implemented? I would rather spend time on my actual work instead of implementing this that has surely been implemented 1000 times before!

Right, but I was wondering if anyone has this implemented? I would rather spend time on my actual work instead of implementing this that has surely been implemented 1000 times before!

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.

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

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

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.