aboutsummaryrefslogtreecommitdiff
path: root/point.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-01-27 22:57:21 +0000
committerrodri <rgl@antares-labs.eu>2023-01-27 22:57:21 +0000
commitfdeaa2423c582df8d9e9ae6b0e26d386b5531262 (patch)
tree26762f0636448354a5c8e6c62756009120dd353e /point.c
parent278c3d3be924246488226ae89e67616955dce661 (diff)
downloadlibgeometry-fdeaa2423c582df8d9e9ae6b0e26d386b5531262.tar.gz
libgeometry-fdeaa2423c582df8d9e9ae6b0e26d386b5531262.tar.bz2
libgeometry-fdeaa2423c582df8d9e9ae6b0e26d386b5531262.zip
bring the slerp function, make ptinpoly public and clean some of the code.
Diffstat (limited to 'point.c')
-rw-r--r--point.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/point.c b/point.c
index e891b02..91634f0 100644
--- a/point.c
+++ b/point.c
@@ -43,8 +43,7 @@ divpt2(Point2 p, double s)
Point2
lerp2(Point2 a, Point2 b, double t)
{
- if(t < 0) t = 0;
- if(t > 1) t = 1;
+ t = fclamp(t, 0, 1);
return Pt2(
flerp(a.x, b.x, t),
flerp(a.y, b.y, t),
@@ -78,7 +77,7 @@ normvec2(Point2 v)
/*
* the edge function, from:
*
- * Juan Pineda, A Parallel Algorithm for Polygon Rasterization,
+ * Juan Pineda, “A Parallel Algorithm for Polygon Rasterization”,
* Computer Graphics, Vol. 22, No. 8, August 1988
*/
int
@@ -97,7 +96,7 @@ edgeptcmp(Point2 e0, Point2 e1, Point2 p)
}
/*
- * algorithm by W. Randolph Franklin
+ * (PNPOLY) algorithm by W. Randolph Franklin
*/
int
ptinpoly(Point2 p, Point2 *pts, ulong npts)
@@ -152,8 +151,7 @@ divpt3(Point3 p, double s)
Point3
lerp3(Point3 a, Point3 b, double t)
{
- if(t < 0) t = 0;
- if(t > 1) t = 1;
+ t = fclamp(t, 0, 1);
return Pt3(
flerp(a.x, b.x, t),
flerp(a.y, b.y, t),