From: Matthew Fernandez Date: Mon, 17 May 2021 02:27:01 +0000 (-0700) Subject: standardize on float arithmetic in trackball() X-Git-Tag: 2.47.3~24^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4de87dbb931be63259b185728197092cd2a1de93;p=graphviz standardize on float arithmetic in trackball() This function was mixing floats and doubles, leading to mixed precision issues. Standardizing on float usage throughout leads to more predictable behavior and removes a number of -Wfloat-conversion warnings. --- diff --git a/cmd/smyrna/trackball.c b/cmd/smyrna/trackball.c index a45e4b07e..91f87ace3 100644 --- a/cmd/smyrna/trackball.c +++ b/cmd/smyrna/trackball.c @@ -59,7 +59,7 @@ * simple example, though, so that is left as an Exercise for the * Programmer. */ -#define TRACKBALLSIZE (0.8) +#define TRACKBALLSIZE 0.8f /* * Local function prototypes (not defined in trackball.h) @@ -156,7 +156,7 @@ void trackball(float q[4], float p1x, float p1y, float p2x, float p2y) if (p1x == p2x && p1y == p2y) { /* Zero rotation */ vzero(q); - q[3] = 1.0; + q[3] = 1.0f; return; } @@ -176,16 +176,16 @@ void trackball(float q[4], float p1x, float p1y, float p2x, float p2y) * Figure out how much to rotate around that axis. */ vsub(p1, p2, d); - t = vlength(d) / (2.0 * TRACKBALLSIZE); + t = vlength(d) / (2.0f * TRACKBALLSIZE); /* * Avoid problems with out-of-control values... */ - if (t > 1.0) - t = 1.0; - if (t < -1.0) - t = -1.0; - phi = 2.0 * asin(t); + if (t > 1.0f) + t = 1.0f; + if (t < -1.0f) + t = -1.0f; + phi = 2.0f * asinf(t); axis_to_quat(a, phi, q); }