diff options
author | rodri <rgl@antares-labs.eu> | 2020-06-28 14:55:44 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2020-06-28 14:55:44 +0000 |
commit | 88e3ce5e4f8a942a5cf8f74aa295f5cab68d781b (patch) | |
tree | e32accc107a8f7d39ed65fac66e3f69043669232 | |
parent | 78a31caf9c482706040a38173c8e2d6913fa282e (diff) | |
download | libgeometry-88e3ce5e4f8a942a5cf8f74aa295f5cab68d781b.tar.gz libgeometry-88e3ce5e4f8a942a5cf8f74aa295f5cab68d781b.tar.bz2 libgeometry-88e3ce5e4f8a942a5cf8f74aa295f5cab68d781b.zip |
add fclamp.
-rw-r--r-- | geometry.h | 1 | ||||
-rw-r--r-- | quaternion.c | 2 | ||||
-rw-r--r-- | utils.c | 6 |
3 files changed, 8 insertions, 1 deletions
@@ -37,6 +37,7 @@ struct Triangle3 { /* utils */ double flerp(double, double, double); +double fclamp(double, double, double); /* Point2 */ Point2 Pt2(double, double, double); diff --git a/quaternion.c b/quaternion.c index 8ef32b8..686c04e 100644 --- a/quaternion.c +++ b/quaternion.c @@ -85,6 +85,6 @@ qrotate(Point3 p, Point3 axis, double θ) θ /= 2; qaxis = Quatvec(cos(θ), mulpt3(axis, sin(θ))); - qr = mulq(mulq(qaxis, Quatvec(0, p)), invq(qaxis)); + qr = mulq(mulq(qaxis, Quatvec(0, p)), invq(qaxis)); /* qpq⁻¹ */ return Pt3(qr.i, qr.j, qr.k, p.w); } @@ -7,3 +7,9 @@ flerp(double a, double b, double t) { return a + (b - a)*t; } + +double +fclamp(double n, double min, double max) +{ + return n < min? min: n > max? max: n; +} |