]> granicus.if.org Git - graphviz/commitdiff
use more appropriate square root function in vlength
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 17 May 2021 02:30:00 +0000 (19:30 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 29 May 2021 00:57:39 +0000 (17:57 -0700)
The square root functions sqrt and sqrtf compute on doubles and floats
respectively. Using the float version here avoids a lossy conversion from double
to float when returning from this function.

cmd/smyrna/trackball.c

index 9c0f61bf312d9136baff0246a2c4271f54c6c705..21d196d84928a49b5f4562778925f76780bd3c8f 100644 (file)
@@ -107,7 +107,7 @@ static void vcross(const float *v1, const float *v2, float *cross)
 
 static float vlength(const float *v)
 {
-    return sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
+    return sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
 }
 
 static void vscale(float *v, float div)