Struct cell_map::Bounds[][src]

pub struct Bounds {
    pub x: (isize, isize),
    pub y: (isize, isize),
}
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

Creates a new empty (zero sized) bound

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.

Gets the slice of other within self, cropping other so it fits within self.

Note that slices are a pair of (min, max) half-open bounds that describe the slice into an array, i.e. they are indices.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

Performance hack: Clone doesn’t get inlined for Copy types in debug mode, so make it inline anyway.

Tests if Self the same as the type T Read more

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.