Skip to content
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

Merged
merged 17 commits into from
Sep 16, 2024
Merged

Generalize dimensions #7

merged 17 commits into from
Sep 16, 2024

Conversation

kitt159
Copy link
Contributor

@kitt159 kitt159 commented Sep 6, 2024

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.

Copy link
Owner

@hmeyer hmeyer left a 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>(
Copy link
Owner

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
Comment on lines 80 to 85
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]),
Copy link
Owner

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>],
Copy link
Owner

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>],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Owner

@hmeyer hmeyer left a 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!

@hmeyer hmeyer merged commit 18eb557 into hmeyer:master Sep 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants