Struct advent_of_code_2021::day_22::Cuboid [−][src]
struct Cuboid {
x_min: isize,
x_max: isize,
y_min: isize,
y_max: isize,
z_min: isize,
z_max: isize,
}Expand description
Represents a cuboid as its range of co-ordinates on each axis. Both values are inclusive.
Fields
x_min: isizex_max: isizey_min: isizey_max: isizez_min: isizez_max: isizeImplementations
Utility so that a Cuboid can be created on a single line (struct literals are always split into multilines by rust-fmt)
If there is an overlap with the incoming Cuboid, return a list of Cuboid slices that
do not that do not intersect, if any. If there is no intersection return this cube,
unaffected.
E.g. in 2D do the following
----------------- self.dff_and_split(&other);
| self |
| --------- |
| | other | |
| --------- |
| |
-----------------
----| |-------| |---- First split on the x axis creating rectangles
| l | | | | r | left and right with their x bounds set to just
| e | |-------| | i | outside the intersecting region.
| f | | other | | g |
| t | |-------| | h |
| | | | | t |
----| |-------| |----
----------
| top |
----| ---------- |---- Then split on the y-axis creating rectangles
| l | | r | top and bottom. Their y bounds set to just
| e | ---------- | i | outside the intersecting region, but their x
| f | | other | | g | bounds are the same as the intersecting region's
| t | ---------- | h | so that they don't overlap left and right at the
| | | t | corners
----| ---------- |----
| bottom |
----------
----| ---------- |---- Just return the slices from self. Other will
| l | | top | | r | only be added to the next iteration if it is
| e | ---------- | i | 'on', which is done elsewhere.
| f | | g |
| t | ---------- | h |
| | | bottom | | t |
----| ---------- |----
Note: Not all slices always get returned e.g. a corner intersect
just creates two slices.
-----
|top|
---------| ----| |---- ----| ----- ----| -----
| self | | L | | | | L | | L | |top|
| -------- => | | |------ => | | ------- => | | -----
----|other | |---| |other| ----| |other| ----|
-------- |------ |------ The above is expanded to three dimensions, but the logic is the same.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Cuboid
impl UnwindSafe for Cuboid
Blanket Implementations
Mutably borrows from an owned value. Read more
