-
Notifications
You must be signed in to change notification settings - Fork 4
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
Generalize dimensions #7
Conversation
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.
Thank you for this PR! Looking forward to getting it merged!
src/lib.rs
Outdated
pub min: na::Point3<S>, | ||
/// X-Y-Z-Maximum corner of the box. | ||
pub max: na::Point3<S>, | ||
fn point_best<S: 'static + Float + Debug, const D: usize>( |
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.
please add a function comment.
consider renaming to: apply_binary_op ?
src/lib.rs
Outdated
fn points_best<S: 'static + Float + Debug, const D: usize>( | ||
points: &[na::Point<S, D>], | ||
op: fn(S, S) -> S, | ||
) -> na::Point<S, D> { | ||
points.iter().fold( | ||
na::Point::from([-op(S::infinity(), S::neg_infinity()); D]), |
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.
This is pretty neat. But also quite clever.
How about renaming it to:
fn fold_points(initial, points, op) -> Point
?
Also make points: Iterator<Point>
?
also please add a function comment
src/lib.rs
Outdated
} | ||
|
||
fn points_min<S: 'static + Float + Debug, const D: usize>( | ||
points: &[na::Point<S, D>], |
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.
This should also be points: impl Iterator<Item = &'a na::Point<S, D>>
, no?
src/lib.rs
Outdated
} | ||
|
||
fn points_max<S: 'static + Float + Debug, const D: usize>( | ||
points: &[na::Point<S, D>], |
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.
same here
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.
Thank you so much!
I have generalized bbox to the generic dimension. Please check if the implementation is correct, especially for the distance function. I think in the future it would be useful to modify the distance function to calculate the exact distance, the current implementation is confusing. I was not able to generalize the transform function, so it is only defined in 3d for now.