summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-07-05 10:41:59 +0000
committerrodri <rgl@antares-labs.eu>2020-07-05 10:41:59 +0000
commit524e19eee808837873435f908fd9b80a372673f8 (patch)
treed0374c300466c1f251c4a0a6c5e0327fd2e0f90c
parent6477319da461ad78a120a3c777228eaa8194c9f8 (diff)
downloadlibgraphics-524e19eee808837873435f908fd9b80a372673f8.tar.gz
libgraphics-524e19eee808837873435f908fd9b80a372673f8.tar.bz2
libgraphics-524e19eee808837873435f908fd9b80a372673f8.zip
move the edge function out into libgeometry.
-rw-r--r--triangle.c30
1 files changed, 0 insertions, 30 deletions
diff --git a/triangle.c b/triangle.c
index 843ff6a..9c49651 100644
--- a/triangle.c
+++ b/triangle.c
@@ -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;
-}