fitplanes.py 681 B

1234567891011121314151617181920212223
  1. """Fit a plane to regions of a surface defined by
  2. N points that are closest to a given point of the surface."""
  3. from vedo import *
  4. apple = Mesh(dataurl+"apple.ply").subdivide().add_gaussian_noise(0.5)
  5. plt = Plotter()
  6. plt += apple.alpha(0.1)
  7. variances = []
  8. for i, p in enumerate(apple.points):
  9. pts = apple.closest_point(p, n=12) # find the N closest points to p
  10. plane = fit_plane(pts) # find the fitting plane
  11. variances.append(plane.variance)
  12. if i % 200: continue
  13. plt += plane
  14. plt += Points(pts)
  15. plt += Arrow(plane.center, plane.center+plane.normal/5)
  16. plt += __doc__ + "\nNr. of fits performed: "+str(len(variances))
  17. plt.show().close()