Computer graphics in Game development
Ivan Belyavtsev
24.10.2020
Let’s take two points \((X, Y)\) and \((X+dx, Y=dy)\)
Define an edge function:
\[E(x, y) = (x - X)dy - (y - Y)dx\]
[1]
If \(E(x, y)>0\) then \((x, y)\) on the “right” side
If \(E(x, y)<0\) then \((x, y)\) on the “left” side
If \(E(x, y)=0\) then \((x, y)\) on the edge
[1]
[1]
[2]
Let’s implement it together
Let exists \[P=uA+vB+wC\], where \(u+v+w=1\)
[3]
\[(u_1, u_2, 0) \times (v_1, v_2, 0) = (0, 0, u_1v_1-u_2v_1)\]
and compare with
\[E(x, y) = (x - X)dy - (y - Y)dx\]
Let’s implement it together