summaryrefslogtreecommitdiff log msg author committer range
diff options
 context: 12345678910152025303540 space: includeignore mode: unifiedssdiffstat only
author committer Nicolas Schodet 2012-05-05 19:02:53 +0200 Nicolas Schodet 2012-05-05 19:02:53 +0200 0fcdbb1904c2f1c32c80ebe4da367742ef6e00bc (patch) c759272b7853cbc0ae4b0941d49ccc7e9291169f /digital/avr/modules/math/geometry/intersection.c e50baf1bcea86bd969b7d87e9dd643607ef7f161 (diff)
digital/avr/modules/math/geometry: slightly change intersection meaning
When a segment end is exactly on the other segment, consider there is no intersection.
Diffstat (limited to 'digital/avr/modules/math/geometry/intersection.c')
-rw-r--r--digital/avr/modules/math/geometry/intersection.c11
1 files changed, 7 insertions, 4 deletions
 diff --git a/digital/avr/modules/math/geometry/intersection.c b/digital/avr/modules/math/geometry/intersection.cindex 1f8a9278..a1daf72d 100644--- a/digital/avr/modules/math/geometry/intersection.c+++ b/digital/avr/modules/math/geometry/intersection.c@@ -25,18 +25,21 @@ #include "common.h" #include "intersection.h" -/** Compare a and b to determine if a / b is in [0:1]. Return non zero if+/** Compare a and b to determine if a / b is in ]0:1[. Return non zero if * true. */ static uint8_t intersection_div_is_in_0_1 (int32_t a, int32_t b) {+ assert (b != 0); /* Test sign, a / b < 0 if different. */- if ((a >> 31) ^ (b >> 31))+ if ((a ^ b) & 0x80000000)+ return 0;+ else if (a == 0) return 0; else if (a > 0)- return a <= b;+ return a < b; else- return a >= b;+ return a > b; } uint8_t