aboutsummaryrefslogtreecommitdiff
path: root/ptinpoly.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-02-01 12:48:36 +0000
committerrodri <rgl@antares-labs.eu>2023-02-01 12:48:36 +0000
commit88a2aed0c2c5450437bd7935eb5847dfdfa50d59 (patch)
treebca357b5615e7c32ece16542d7452e850a76a3ca /ptinpoly.c
parent367b5a4c7a7ca100e55bf214471cdaabae0a2014 (diff)
downloadetoys-88a2aed0c2c5450437bd7935eb5847dfdfa50d59.tar.gz
etoys-88a2aed0c2c5450437bd7935eb5847dfdfa50d59.tar.bz2
etoys-88a2aed0c2c5450437bd7935eb5847dfdfa50d59.zip
made it work with the current libgeometry provided by the system.
Diffstat (limited to 'ptinpoly.c')
-rw-r--r--ptinpoly.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/ptinpoly.c b/ptinpoly.c
index 68d7c0c..ce8d945 100644
--- a/ptinpoly.c
+++ b/ptinpoly.c
@@ -69,17 +69,18 @@ newpolygon(Point2 *pts, int npts)
return poly;
}
-int
-ptinpoly(Point2 p, Polygon poly)
-{
- int i, j, c;
+//int
+//ptinpoly(Point2 p, Polygon poly)
+//{
+// int i, j, c;
+//
+// for(i = c = 0, j = poly.npts-1; i < poly.npts; j = i++)
+// if(p.y < poly.pts[i].y != p.y < poly.pts[j].y &&
+// p.x < (poly.pts[j].x - poly.pts[i].x) * (p.y - poly.pts[i].y)/(poly.pts[j].y - poly.pts[i].y) + poly.pts[i].x)
+// c ^= 1;
+// return c;
+//}
- for(i = c = 0, j = poly.npts-1; i < poly.npts; j = i++)
- if(p.y < poly.pts[i].y != p.y < poly.pts[j].y &&
- p.x < (poly.pts[j].x - poly.pts[i].x) * (p.y - poly.pts[i].y)/(poly.pts[j].y - poly.pts[i].y) + poly.pts[i].x)
- c ^= 1;
- return c;
-}
Point
toscreen(Point2 p)
@@ -137,7 +138,7 @@ void
rmb(Mousectl *mc)
{
thepoint = fromscreen(mc->xy);
- isinside = ptinpoly(thepoint, *thepoly);
+ isinside = ptinpoly(thepoint, thepoly->pts, thepoly->npts);
}
void