This project describes two ways to detect if a point P is inside a triangle on the coordinate plane. Press space to switch between them. Drag the colored dots to move the points of the triangle. Barycentric: Create a completely new coordinate plane with two sides of the triangle as the new axes. The coordinates can be shown with the grid as shown. Now represent the arbitrary point P by the new coordinates. If the new coordinates meet a certain constraint, then point P is inside the triangle, and outside if otherwise. Linear Inequality: Imagine that point P is inside the triangle if it is on a certain side of each side of the triangle. Determine if P satisfies this, using three inequalities derived from the form Y ? (X(yb - ya) - xa*yb + xb*ya )/(xb - xa), where P=(X, Y), ? represents an inequality symbol, and (xa, ya) and (xb, yb) are the coordinates of an arbitrary line. If P satisfies all three inequalities, then P is inside the triangle, and outside if otherwise. (For an EQUALITY, Y=(X(yb - ya) - xa*yb + xb*ya )/(xb - xa), which is derived from (y - ya)/(x - xa)=(yb - ya)/(xb - xa), meaning (X, Y) is on the line.)
Barycentric Method: thanks to @Zro716 for the idea. https://scratch.mit.edu/projects/24967895/ Side-Inequality Method: me