Struct cell_map::Bounds [−][src]
Expand description
Rectangular bounds describing the number of cells in each direction of the map.
These bounds are a half-open range, i.e. satisfied in the ranges:
- $x_0 <= x < x_1$
- $y_0 <= y < y_1$
Fields
x: (isize, isize)
The bounds on the x axis, in the format (min, max),
y: (isize, isize)
The bounds on the y axis, in the format (min, max),
Implementations
Returns if the bounds are valid or not, i.e. if the minimum is larger than the maximum.
Creates a new bound from the given max and min cell indices in the x and y axes.
Must satisfy:
- $x_0 <= x_1$
- $y_0 <= y_1$
Creates a new bound from the given opposing corners of the a rectangle.
If the corners do not satisfy all(bottom_left <= upper_right)
the bounds will be invalid
and an error is returned.
Creates a new bound from the given opposing corners of the a rectangle, but the corners do not have to be sorted in bottom_left, upper_right order.
This function will automatically decide which points are provided such that the bounds will be valid.
Converts this bounds into a pair of corners, the bottom left and upper right corners respectively.
Checks if the given point is inside the bounds
Gets the value of the point as an index into an array bounded by this Bounds
.
If the point is outside the bounds None
is returned
Gets the value of the point as an index into an array bounded by this Bounds
.
Safety
This function will not panic if point
is outside the map, but use of the result to
index into the map is not guaranteed to be safe. It is possible for this function to return
a negative index value, which would indicate that the cell is outside the map.
Gets the shape of this rectangle in a format that ndarray
will accept.
NOTE: shape order is (y, x), not (x, y).
Gets the number of cells as a vector.
Gets the intersection of self with other, returning None
if the two do not intersect.
Get the union of self
with other
, effectively this is the axis aligned bounding box of
self
and other
.
If both bounds are empty this bound will be empty.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Bounds
impl UnwindSafe for Bounds
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.