]> granicus.if.org Git - graphviz/commitdiff
dotgen leftOf: perform computation in double range
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Sep 2022 00:27:49 +0000 (17:27 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 29 Jan 2023 16:24:43 +0000 (08:24 -0800)
It is not clear to me why this code was implicitly converting the result of its
computation to `int`. Doing the entire thing in `double` is more precise and
squashes a compiler warning.

lib/dotgen/dotsplines.c

index 15c19475537641d065c8c253831a5a2b302f51f5..5d35c588ff070c2a898b03c3ab7905e11c541a17 100644 (file)
@@ -1677,10 +1677,7 @@ make_flat_edge(graph_t* g, spline_info_t* sp, path * P, edge_t ** edges, int ind
 static int
 leftOf (pointf p1, pointf p2, pointf p3)
 {
-    int d;
-
-    d = (p1.y - p2.y) * (p3.x - p2.x) - (p3.y - p2.y) * (p1.x - p2.x);
-    return d > 0;
+  return (p1.y - p2.y) * (p3.x - p2.x) - (p3.y - p2.y) * (p1.x - p2.x) > 0;
 }
 
 /* makeLineEdge: