From 4c2c509aad3740528df96248c9d14289770da1be Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 4 May 2012 21:59:56 +0200 Subject: host/simu/utils/intersect: fix sign of expression This does not change anything because sign is inverted on numerator and denominator. --- host/simu/utils/intersect.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/host/simu/utils/intersect.py b/host/simu/utils/intersect.py index 6074dda0..35ac38af 100644 --- a/host/simu/utils/intersect.py +++ b/host/simu/utils/intersect.py @@ -50,24 +50,24 @@ def segment_segment (a, b, c, d): # v = ----------------------------------------- # (xb - xa) (yd - yc) - (xd - xc) (yb - ya) # - # u = (vac . vcd.normal()) / (vab . vcd.normal()) - # v = (vac . vab.normal()) / (vab . vcd.normal()) + # u = (vac.normal() . vcd) / (vab.normal() . vcd) + # v = (vac.normal() . vab) / (vab.normal() . vcd) # - # If vab . vcd.normal () is 0, AB and CD are parallel. + # If vab.normal() . vcd is 0, AB and CD are parallel. vab = b - a vcd = d - c vac = c - a # Cannot test for 0 because we are using float, cannot test for a very # small number because we do not know what is small enough, therefore, # compare with numerator. - den = vab * vcd.normal () - unum = vac * vcd.normal () + den = vab.normal () * vcd + unum = vac.normal () * vcd if abs (den) <= 1e-6 * abs (unum): return None else: u = unum / den if u >= 0 and u <= 1: - v = vac * vab.normal () / den + v = vac.normal () * vab / den if v >= 0 and v <= 1: return u * vab.norm () return None -- cgit v1.2.3