andreesteve / voronoice

A nice and fast way to construct 2D Voronoi Diagrams
MIT License
34 stars 9 forks source link

add Clone to vertices iter #14

Closed vjackson725 closed 2 years ago

vjackson725 commented 2 years ago

Hi,

I was trying to use .cycle() on the vertices iterator, and noticed it didn't have Clone. Being able to use cycle is useful for computing the area of simple polygons, e.g.

cell.iter_vertices()
          .cycle()
          .take(cell.iter_vertices().count()+1)
          .tuple_windows() // from Itertools
          .map(|(a,b)| a.x*b.y - b.x*a.y)
          .sum::<f64>()
          .abs()
andreesteve commented 2 years ago

Thank you! I feel the iterators exposed need somehow to be better defined. Either behind a trait or its own type. I can see how we may hit other missing traits on the existing iterators that will make it harder to chain then further. That would be a nice future improvement.