benbaarber / quadtree

Generic QuadTree implementation in Rust
https://crates.io/crates/quadtree
MIT License
0 stars 0 forks source link

Shapes aren't generic #1

Closed ejjonny closed 1 week ago

ejjonny commented 1 month ago

"Generic Implementation: Works with any data type that implements the Point trait."

This doesn't seem to be quite right - Rect can only be constructed with nalgebra::Point & none of the objects containing P2 are generic.

Side note - it may be more idiomatic to use Into<P2> in the interface if the Point trait is simply a conversion, & if it's not a conversion, it should model whatever interface required from nalgebra::point

& a side side note - ideally, users of the library shouldn't need to depend on nalgebra directly & the required types could be re-exposed with a pub use in lib.rs.

ejjonny commented 1 month ago

If you're open to it I wouldn't mind taking a crack at some of these when I have some time

benbaarber commented 1 month ago

Thanks for the feedback!

"Generic Implementation: Works with any data type that implements the Point trait." This doesn't seem to be quite right - Rect can only be constructed with nalgebra::Point & none of the objects containing P2 are generic.

The quote is referring to the data type T that is stored in QuadTree<T>, which is defined by the user. The Shape trait and its implementors (just Rect and Circle for now) are specifically for spacial querying.

Side note - it may be more idiomatic to use Into in the interface if the Point trait is simply a conversion, & if it's not a conversion, it should model whatever interface required from nalgebra::point

In this case it's not a conversion, it's a property accessor method. Implementing Point is just a way of providing the 2d position of whatever data type T the user defines.

& a side side note - ideally, users of the library shouldn't need to depend on nalgebra directly & the required types could be re-exposed with a pub use in lib.rs.

Good call, will include this in the next release.