Skip to content

Commit

Permalink
Adds the Box3D::from_origin_and_size associated function. (#520)
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Whitman <daniel.whitman.2@us.af.mil>
  • Loading branch information
kyp44 and Dan Whitman authored Mar 22, 2024
1 parent 7c973a1 commit b27ae33
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/box3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ impl<T, U> Box3D<T, U> {
Box3D { min, max }
}

/// Constructor.
#[inline]
pub fn from_origin_and_size(origin: Point3D<T, U>, size: Size3D<T, U>) -> Self
where
T: Copy + Add<T, Output = T>,
{
Box3D {
min: origin,
max: point3(
origin.x + size.width,
origin.y + size.height,
origin.z + size.depth,
),
}
}

/// Creates a Box3D of the given size, at offset zero.
#[inline]
pub fn from_size(size: Size3D<T, U>) -> Self
Expand Down

0 comments on commit b27ae33

Please sign in to comment.