Drag the points of the triangle.
http://www.blackpawn.com/texts/pointinpoly/ In this tutorial I'm showcasing a nifty trick for figuring out if a point lies within a triangular plane. The trick relies on barycentric coordinates, or in other words parameter values u and v. So what could this be used for? The project I shared after this utilizes the barycentric method to calculate the needed y position of the player on a 3D triangle-- how I did this was simply pretend the triangle is 2D from the top, then use the u and v parameters. In that respect, the possibilities for recreations of professional games is within our grasp! Given triangle points A B and C and an arbitrary point P, the barycentric values u and v are calculated as such: // Compute vectors v0 = C - A v1 = B - A v2 = P - A // Compute dot products dot00 = dot(v0, v0) dot01 = dot(v0, v1) dot02 = dot(v0, v2) dot11 = dot(v1, v1) dot12 = dot(v1, v2) // Compute barycentric coordinates invDenom = 1 / (dot00 * dot11 - dot01 * dot01) u = (dot11 * dot02 - dot01 * dot12) * invDenom v = (dot00 * dot12 - dot01 * dot02) * invDenom // Check if point is in triangle return (u >= 0) && (v >= 0) && (u + v < 1)