-
Notifications
You must be signed in to change notification settings - Fork 205
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
Robust ExtremePoint trait #505
Conversation
@urschrei @frewsxcv The Should we remove that functionality from It is only used in a couple of |
This makes sense to me. It would be kinder to deprecate it, change the internal impls to use the robust versions, and remove it after some time has passed. |
geo-types/src/coordinate.rs
Outdated
|
||
/// Construct a point at the origin, that is, with both | ||
/// `x` and `y` coordinates as zero. | ||
pub fn zero() -> Self { |
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've wanted this little method many times.
1. add `IsConvex` trait and documentation of predicates. 1. add vector space ops in `Coordinate`. These were earlier available in `Point`, but it makes more sense to be available for `Coordinate` too. 1. many minor doc improvements: explain corner cases, better references, fix spellings (collinear). Oh, btw, please skip ci !
9922800
to
9ea0c90
Compare
@michaelkirk @urschrei I'm quite confused about the For now, I'm going to leave this trait as is, and just make a few calls robust. Some clarity on the purpose of this trait would be very helpful. |
…x/robust-extremes
Impl `Div`, `Mul` by scalar for both `Coordinate` and `Point`.
Two things:
edit: no more late-night posting. |
@urschrei Got it. We currently use |
+ remove `Float` requirement + doc fixes for stable rust + remove `<T>` from `Extreme{Point,Indices}`
On a side note: the check whether to use the "rotating calipers" fast path in if poly2.is_convex() || !self.is_convex() Shouldn't it check if both are convex? It seems to want one of them to not be convex. |
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.
LGTM!
All my feedback was optional.
Point::new(T::one(), T::zero()), | ||
Point::new(T::zero(), T::one()), | ||
Point::new(-T::one(), T::zero()), | ||
let directions: Vec<Coordinate<_>> = vec![ |
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.
no biggie so take it or leave it, but since this is fixed size we could make this an array instead of a vec.
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 don't think fixed size works here because it is not an iterator. We can re-visit this once we have the ForEachCoord
trait, and simplify the logic here.
if allow_collinear { | ||
None | ||
} else { | ||
Some((i, orientation)) |
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.
A little clarity nit:
At this point, find_first_non_collinear is in fact collinear, right?
To me that reads like let not_a_dog = 🐕;
Would something like starting_orientation
be clearer than find_first_non_collinear
?
No biggie though, it just tripped me up as I was trying to understand.
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.
So, the first loop is in fact finding the first non-collinear orientation; we return collinear in that loop only if !allow_collinear, and as a fast exit path. The apparent inversion is unfortunately how find
/ find_map
works: it shorts at the first Some()
return from the closure.
efde663
to
1e32bcb
Compare
+ deprecate `Polygon::is_convex` in favour of the robust algorithm in geo + fix fast path condition in euclidean distance between `Polygon`s + doc fixes
1e32bcb
to
f5d1349
Compare
bors r=michaelkirk |
Build succeeded: |
This PR introduces
IsConvex
trait, and partially revamps theExtremePoint
trait.add
IsConvex
trait and documentation of predicates.add vector space ops in
Coordinate
. These were earlieravailable in
Point
, but it makes more sense to beavailable for
Coordinate
too.many minor doc improvements: explain corner cases,
better references, fix spellings (collinear).
make
ExtremePoint
robustRemove unneeded trait generic parameter
T
, and requirementT: Float
Things to revamp / discuss in
ExtremePoint
convex_hull
in the impl?Result<Extremes, ()>
withOption