24th May
2010
written by admin

Determining if a point is in a 2D triangle

Visual Studio 2008 Project and Source here

For this one I needed to read in a file of a ton of triangles and then process them to determine if a point is contained in the triangle.  I thought of a couple different algorithms to solve this but ultimately decided to use the cross product between the generated segments to determine if it is contained.  I had been needing a basic File class for reading and writing files, so I set one of those up, then I moved to the 2D integer vector class that I used for the math needed to solve it.  The parsing is very basic I just scan for the integers, then i sorted the points from left to right so I knew how to process the triangle.

Anyway check it out and leave some feedback.