diff options
author | David Runge <dave@sleepmap.de> | 2016-01-04 13:40:12 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2016-01-04 13:40:12 +0100 |
commit | 8b4f7ef465921ce620df31b005c870b4deb3103a (patch) | |
tree | 9632ad6bd5f3ebda1d309af70b9f6a649baba4b9 /AutoVisual | |
parent | f527b87d09d686f8e7cb355aaa5da0fa17136c67 (diff) | |
download | processing-sketchbook-8b4f7ef465921ce620df31b005c870b4deb3103a.tar.gz processing-sketchbook-8b4f7ef465921ce620df31b005c870b4deb3103a.tar.bz2 processing-sketchbook-8b4f7ef465921ce620df31b005c870b4deb3103a.tar.xz processing-sketchbook-8b4f7ef465921ce620df31b005c870b4deb3103a.zip |
AutoVisual/IGPFamily.pde: Fixing getVectorOnExtendedLine() function to honor lines with infinite slope.
Diffstat (limited to 'AutoVisual')
-rw-r--r-- | AutoVisual/IGPFamily.pde | 14 |
1 files 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); } |