Skip to content

Commit

Permalink
Add GridAab::from_ranges().
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Nov 26, 2023
1 parent 0e00475 commit cf3d6e2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions all-is-cubes/src/math/grid_aab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ impl GridAab {
GridAab::from_lower_size(lower_bounds, upper_bounds.into() - lower_bounds)
}

/// Constructs a [`GridAab`] from [`Range`]s.
///
/// This is identical to [`GridAab::from_lower_upper()`] except for the input type.
#[track_caller]
pub fn from_ranges(ranges: impl Into<Vector3D<Range<GridCoordinate>, Cube>>) -> GridAab {
let ranges = ranges.into();
GridAab::from_lower_upper(
ranges.clone().map(|r| r.start).to_point(),
ranges.map(|r| r.end).to_point(),
)
}

/// Constructs a [`GridAab`] from inclusive lower bounds and exclusive upper bounds.
///
/// Returns [`Err`] if the bounds are reversed or the resulting range would cause
Expand Down

0 comments on commit cf3d6e2

Please sign in to comment.