diff options
-rw-r--r-- | triangle.c | 30 |
1 files changed, 0 insertions, 30 deletions
@@ -4,27 +4,6 @@ #include <geometry.h> #include <graphics.h> -/* - * comparison of a point p with an edge [e0 e1] - * p to the right: + - * p to the left: - - * p on the edge: 0 - */ -static int -edgeptcmp(Point e0, Point e1, Point p) -{ - Point3 e0p, e01, r; - - p = subpt(p, e0); - e1 = subpt(e1, e0); - e0p = Vec3(p.x,p.y,0); - e01 = Vec3(e1.x,e1.y,0); - r = crossvec3(e0p, e01); - - /* clamp to avoid overflow */ - return fclamp(r.z, -1, 1); /* e0.x*e1.y - e0.y*e1.x */ -} - Triangle Trian(int x0, int y0, int x1, int y1, int x2, int y2) { @@ -61,12 +40,3 @@ filltriangle(Image *dst, Triangle t, Image *src, Point sp) fillpoly(dst, pl, nelem(pl), 0, src, sp); } - -int -ptintriangle(Point p, Triangle t) -{ - /* counter-clockwise check */ - return edgeptcmp(t.p0, t.p2, p) <= 0 && - edgeptcmp(t.p2, t.p1, p) <= 0 && - edgeptcmp(t.p1, t.p0, p) <= 0; -} |