Permafacture / Py-Visvalingam-Whyatt

Python implementation of Visvalingam and Whyatt's algorithm for reducing the complexity of poly-lines
45 stars 12 forks source link

Use numpy correctly to calculate triangle areas #7

Closed Permafacture closed 9 years ago

Permafacture commented 9 years ago
    pts = self.pts
    nmax = len(pts)
    real_areas = array([triangle_area(pts[n-1],pts[n],pts[n+1]) if n not in [0,nmax-1] else np.inf for n in range(nmax)])

AGH! creating an array from a list comprehension looping over an array!? What was I thinking?

Permafacture commented 9 years ago

Fixed. Brought 1/3 of triangle area calculations to essentially zero time. Overall not a huge improvement. (OldTime - NewTime) / OldTime = 17%