I modified this so that it doesn't add the last point to the result list.  This prevents the same point being added twice.  The function `scaleToSurface` adds the final point in the list.  I added documentation for this.