-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement distance traits for more geometries #113
Conversation
These are just the inverse of existing impls, provided for convenience
@@ -10,10 +10,10 @@ use num_traits::pow::pow; | |||
pub trait Distance<T, Rhs = Self> { | |||
/// Returns the distance between two geometries | |||
/// | |||
/// If a `Point` is contained by a `Polygon`, the distance is `0.0` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these spaces might have been intentional because markdown treats them as newlines:
http://spec.commonmark.org/0.26/#hard-line-breaks
I think with your changes, these sentences get put on the same line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Fixed.
Thanks for this! It's unfortunate that we can't do something like #73 bors r+ |
113: Implement distance traits for more geometries r=frewsxcv This PR adds distance traits for all geometries for which the trait was already implemented in one direction. E.g. if `Point`-to-`Polygon` distance existed, `Polygon`-to-`Point` distance now also exists. This adds a few boilerplate functions, but I can't think of a more ergonomic solution. Still missing: - `LineString`-to-`LineString` minimum distance (is there a good algorithm for this?) - `Polygon`-to-`Polygon` minimum distance (I'm (slowly) working on a [rotating calipers](http://web.archive.org/web/20150407022621/http://cgm.cs.mcgill.ca/~orm/mind2p.html) implementation)
Build succeeded |
That would be great, and I did wonder whether something like that would be possible given the symmetry of |
This PR adds distance traits for all geometries for which the trait was already implemented in one direction. E.g. if
Point
-to-Polygon
distance existed,Polygon
-to-Point
distance now also exists. This adds a few boilerplate functions, but I can't think of a more ergonomic solution.Still missing:
LineString
-to-LineString
minimum distance (is there a good algorithm for this?)Polygon
-to-Polygon
minimum distance (I'm (slowly) working on a rotating calipers implementation)