From 8b4f7ef465921ce620df31b005c870b4deb3103a Mon Sep 17 00:00:00 2001 From: David Runge Date: Mon, 4 Jan 2016 13:40:12 +0100 Subject: AutoVisual/IGPFamily.pde: Fixing getVectorOnExtendedLine() function to honor lines with infinite slope. --- AutoVisual/IGPFamily.pde | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/AutoVisual/IGPFamily.pde b/AutoVisual/IGPFamily.pde index 78e3f2f..7b97c6f 100644 --- a/AutoVisual/IGPFamily.pde +++ b/AutoVisual/IGPFamily.pde @@ -241,10 +241,20 @@ class IGPFamily { PVector getVectorOnExtendedLine(PVector startPoint, PVector endPoint, float boundary, boolean vertical){ float m,n; - m = (endPoint.y-startPoint.y)/(endPoint.x-startPoint.x); + boolean dirac = false; + if (endPoint.x-startPoint.x == 0){ + dirac = true; + m = 0; + } else { + m = (endPoint.y-startPoint.y)/(endPoint.x-startPoint.x); + } n = endPoint.y-m*endPoint.x; if (vertical){ - return new PVector((boundary-n)/m, boundary); + if (dirac){ + return new PVector(startPoint.x, boundary); + }else{ + return new PVector((boundary-n)/m, boundary); + } } else { return new PVector(boundary, (m*boundary)+n); } -- cgit v1.2.3-70-g09d2