|
Author |
Topic: inside triangle (Read 1511 times) |
|
kevinP
|
inside triangle
« on: Feb 14th, 2004, 11:42pm » |
|
Nothing fancy, but here's a solution I found for checking if a point is inside a triangle. I had found a solution using "crossed products" (compares vectors of triangle sides to vector between point and one vertex) but the formulas I saw were for three coordinates and I could not see how to convert it to 2D. Then I found a link to "barycentric coordinates," which to me looks very similar to the crossed products solution. http://www.tiros.net/pfeiffer/processing/2004/insideTriangle/ [I modified this further. It now checks first to see if the test coordinates are inside a bounding box for the triangle and only then does the calculations to check for the triangle. Someone mentioned this somewhere and it sounded like a good idea to me.] -K
|
« Last Edit: Mar 20th, 2004, 1:36am by kevinP » |
|
Kevin Pfeiffer
|
|
|
|