summaryrefslogtreecommitdiff
path: root/graphics.c
diff options
context:
space:
mode:
Diffstat (limited to 'graphics.c')
-rw-r--r--graphics.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/graphics.c b/graphics.c
index ec86b42..3a4138c 100644
--- a/graphics.c
+++ b/graphics.c
@@ -312,18 +312,15 @@ b8 rectangle_contains(f64 x0, f64 y0, f64 width, f64 height, f64 px, f64 py) {
b8 triangle_contains(f64 x0, f64 y0, f64 x1, f64 y1, f64 x2, f64 y2, f64 px, f64 py) {
// Z-components of cross-products
//
+
f64 z0 = (x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0);
f64 z1 = (x2 - x1) * (y0 - y1) - (x0 - x1) * (y2 - y1);
f64 z2 = (x0 - x2) * (y1 - y2) - (x1 - x2) * (y0 - y2);
- // Z-components of cross-products
- //
f64 pz0 = (px - x0) * (y2 - y0) - (x2 - x0) * (py - y0);
f64 pz1 = (px - x1) * (y0 - y1) - (x0 - x1) * (py - y1);
f64 pz2 = (px - x2) * (y1 - y2) - (x1 - x2) * (py - y2);
- // Check signs
- //
return
same_sign(z0, pz0)
&& same_sign(z1, pz1)