diff options
author | rodri <rgl@antares-labs.eu> | 2023-01-28 22:16:25 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-01-28 22:16:25 +0000 |
commit | 983fae140a1e162d947eab8b8a0d9acba291d3a8 (patch) | |
tree | ef7a0de9a51ebbfd086e9293d2a22e1da387ee2d /util.c | |
download | threedee-983fae140a1e162d947eab8b8a0d9acba291d3a8.tar.gz threedee-983fae140a1e162d947eab8b8a0d9acba291d3a8.tar.bz2 threedee-983fae140a1e162d947eab8b8a0d9acba291d3a8.zip |
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> +#include "dat.h" +#include "fns.h" + +double +round(double n) +{ + return floor(n + 0.5); +} + +Point +rotatept(Point p, double θ, Point c) +{ + Point r; + + p = subpt(p, c); + r.x = round(p.x*cos(θ) - p.y*sin(θ)); + r.y = round(p.x*sin(θ) + p.y*cos(θ)); + r = addpt(r, c); + return r; +} + +double +hypot3(double x, double y, double z) +{ + return hypot(x, hypot(y, z)); +} |