Expand description
An axis-aligned bounded 2D rectangle whose area is
defined by minimum and maximum Coordinate
s.
The constructors and setters ensure the maximum
Coordinate
is greater than or equal to the minimum.
Thus, a Rect
s width, height, and area is guaranteed to
be greater than or equal to zero.
Note. While Rect
implements MapCoords
and
RotatePoint
algorithmic traits, the usage is expected
to maintain the axis alignment. In particular, only
rotation by integer multiples of 90 degrees, will
preserve the original shape. In other cases, the min,
and max points are rotated or transformed, and a new
rectangle is created (with coordinate swaps to ensure
min < max).
Examples
use geo_types::{coord, Rect};
let rect = Rect::new(
coord! { x: 0., y: 4.},
coord! { x: 3., y: 10.},
);
assert_eq!(3., rect.width());
assert_eq!(6., rect.height());
assert_eq!(
coord! { x: 1.5, y: 7. },
rect.center()
);
Implementations
sourceimpl<T> Rect<T> where
T: CoordNum,
impl<T> Rect<T> where
T: CoordNum,
sourcepub fn new<C>(c1: C, c2: C) -> Rect<T> where
C: Into<Coordinate<T>>,
pub fn new<C>(c1: C, c2: C) -> Rect<T> where
C: Into<Coordinate<T>>,
Creates a new rectangle from two corner coordinates.
Examples
use geo_types::{coord, Rect};
let rect = Rect::new(
coord! { x: 10., y: 20. },
coord! { x: 30., y: 10. }
);
assert_eq!(rect.min(), coord! { x: 10., y: 10. });
assert_eq!(rect.max(), coord! { x: 30., y: 20. });
pub fn try_new<C>(c1: C, c2: C) -> Result<Rect<T>, InvalidRectCoordinatesError> where
C: Into<Coordinate<T>>,
Use Rect::new
instead, since Rect::try_new
will never Error
sourcepub fn min(self) -> Coordinate<T>
pub fn min(self) -> Coordinate<T>
Returns the minimum Coordinate
of the Rect
.
Examples
use geo_types::{coord, Rect};
let rect = Rect::new(
coord! { x: 5., y: 5. },
coord! { x: 15., y: 15. },
);
assert_eq!(rect.min(), coord! { x: 5., y: 5. });
sourcepub fn set_min<C>(&mut self, min: C) where
C: Into<Coordinate<T>>,
pub fn set_min<C>(&mut self, min: C) where
C: Into<Coordinate<T>>,
Set the Rect
’s minimum coordinate.
Panics
Panics if min
’s x/y is greater than the maximum coordinate’s x/y.
sourcepub fn max(self) -> Coordinate<T>
pub fn max(self) -> Coordinate<T>
Returns the maximum Coordinate
of the Rect
.
Examples
use geo_types::{coord, Rect};
let rect = Rect::new(
coord! { x: 5., y: 5. },
coord! { x: 15., y: 15. },
);
assert_eq!(rect.max(), coord! { x: 15., y: 15. });
sourcepub fn set_max<C>(&mut self, max: C) where
C: Into<Coordinate<T>>,
pub fn set_max<C>(&mut self, max: C) where
C: Into<Coordinate<T>>,
Set the Rect
’s maximum coordinate.
Panics
Panics if max
’s x/y is less than the minimum coordinate’s x/y.
sourcepub fn width(self) -> T
pub fn width(self) -> T
Returns the width of the Rect
.
Examples
use geo_types::{coord, Rect};
let rect = Rect::new(
coord! { x: 5., y: 5. },
coord! { x: 15., y: 15. },
);
assert_eq!(rect.width(), 10.);
sourcepub fn height(self) -> T
pub fn height(self) -> T
Returns the height of the Rect
.
Examples
use geo_types::{coord, Rect};
let rect = Rect::new(
coord! { x: 5., y: 5. },
coord! { x: 15., y: 15. },
);
assert_eq!(rect.height(), 10.);
sourcepub fn to_polygon(self) -> Polygon<T>
pub fn to_polygon(self) -> Polygon<T>
Create a Polygon
from the Rect
.
Examples
use geo_types::{coord, Rect, polygon};
let rect = Rect::new(
coord! { x: 0., y: 0. },
coord! { x: 1., y: 2. },
);
assert_eq!(
rect.to_polygon(),
polygon![
(x: 0., y: 0.),
(x: 0., y: 2.),
(x: 1., y: 2.),
(x: 1., y: 0.),
(x: 0., y: 0.),
],
);
pub fn to_lines(&self) -> [Line<T>; 4]
sourcepub fn split_x(self) -> [Rect<T>; 2]
pub fn split_x(self) -> [Rect<T>; 2]
Split a rectangle into two rectangles along the X-axis with equal widths.
Examples
let rect = geo_types::Rect::new(
geo_types::coord! { x: 0., y: 0. },
geo_types::coord! { x: 4., y: 4. },
);
let [rect1, rect2] = rect.split_x();
assert_eq!(
geo_types::Rect::new(
geo_types::coord! { x: 0., y: 0. },
geo_types::coord! { x: 2., y: 4. },
),
rect1,
);
assert_eq!(
geo_types::Rect::new(
geo_types::coord! { x: 2., y: 0. },
geo_types::coord! { x: 4., y: 4. },
),
rect2,
);
sourcepub fn split_y(self) -> [Rect<T>; 2]
pub fn split_y(self) -> [Rect<T>; 2]
Split a rectangle into two rectangles along the Y-axis with equal heights.
Examples
let rect = geo_types::Rect::new(
geo_types::coord! { x: 0., y: 0. },
geo_types::coord! { x: 4., y: 4. },
);
let [rect1, rect2] = rect.split_y();
assert_eq!(
geo_types::Rect::new(
geo_types::coord! { x: 0., y: 0. },
geo_types::coord! { x: 4., y: 2. },
),
rect1,
);
assert_eq!(
geo_types::Rect::new(
geo_types::coord! { x: 0., y: 2. },
geo_types::coord! { x: 4., y: 4. },
),
rect2,
);
sourceimpl<T> Rect<T> where
T: CoordFloat,
impl<T> Rect<T> where
T: CoordFloat,
sourcepub fn center(self) -> Coordinate<T>
pub fn center(self) -> Coordinate<T>
Returns the center Coordinate
of the Rect
.
Examples
use geo_types::{coord, Rect};
let rect = Rect::new(
coord! { x: 5., y: 5. },
coord! { x: 15., y: 15. },
);
assert_eq!(rect.center(), coord! { x: 10., y: 10. });
Trait Implementations
sourceimpl<T> AbsDiffEq<Rect<T>> for Rect<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
impl<T> AbsDiffEq<Rect<T>> for Rect<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
sourcefn abs_diff_eq(
&self,
other: &Rect<T>,
epsilon: <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &Rect<T>,
epsilon: <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
) -> bool
Equality assertion with an absolute limit.
Examples
use geo_types::{point, Rect};
let a = Rect::new((0.0, 0.0), (10.0, 10.0));
let b = Rect::new((0.0, 0.0), (10.01, 10.0));
approx::abs_diff_eq!(a, b, epsilon=0.1);
approx::abs_diff_ne!(a, b, epsilon=0.001);
type Epsilon = T
type Epsilon = T
Used for specifying relative comparisons.
sourcefn default_epsilon() -> <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
fn default_epsilon() -> <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of [AbsDiffEq::abs_diff_eq
].
sourceimpl<T> Area<T> for Rect<T> where
T: CoordNum,
impl<T> Area<T> for Rect<T> where
T: CoordNum,
Because a Rect
has no winding order, the area will always be positive.
fn signed_area(&self) -> T
fn unsigned_area(&self) -> T
sourceimpl<T> BoundingRect<T> for Rect<T> where
T: CoordNum,
impl<T> BoundingRect<T> for Rect<T> where
T: CoordNum,
sourceimpl<T> ChamberlainDuquetteArea<T> for Rect<T> where
T: CoordFloat,
impl<T> ChamberlainDuquetteArea<T> for Rect<T> where
T: CoordFloat,
fn chamberlain_duquette_signed_area(&self) -> T
fn chamberlain_duquette_unsigned_area(&self) -> T
sourceimpl<F: GeoFloat> ClosestPoint<F, Point<F>> for Rect<F>
impl<F: GeoFloat> ClosestPoint<F, Point<F>> for Rect<F>
sourcefn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
Find the closest point between self
and p
.
sourceimpl<T> Contains<Coordinate<T>> for Rect<T> where
T: CoordNum,
impl<T> Contains<Coordinate<T>> for Rect<T> where
T: CoordNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
sourceimpl<F> Contains<Rect<F>> for MultiPolygon<F> where
F: GeoFloat,
impl<F> Contains<Rect<F>> for MultiPolygon<F> where
F: GeoFloat,
sourceimpl<T> CoordinatePosition for Rect<T> where
T: GeoNum,
impl<T> CoordinatePosition for Rect<T> where
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
sourceimpl<'a, T: CoordNum + 'a> CoordsIter<'a> for Rect<T>
impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Rect<T>
sourcefn coords_count(&'a self) -> usize
fn coords_count(&'a self) -> usize
Return the number of coordinates in the Rect
.
Note: Although a Rect
is represented by two coordinates, it is
spatially represented by four, so this method returns 4
.
type Iter = Chain<Chain<Chain<Once<Coordinate<T>>, Once<Coordinate<T>>>, Once<Coordinate<T>>>, Once<Coordinate<T>>>
type ExteriorIter = <Rect<T> as CoordsIter<'a>>::Iter
type Scalar = T
sourcefn coords_iter(&'a self) -> Self::Iter
fn coords_iter(&'a self) -> Self::Iter
Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
sourcefn exterior_coords_iter(&'a self) -> Self::ExteriorIter
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
Iterate over all exterior coordinates of a geometry. Read more
sourceimpl<T> Densify<T> for Rect<T> where
T: CoordFloat,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
impl<T> Densify<T> for Rect<T> where
T: CoordFloat,
Line<T>: EuclideanLength<T>,
LineString<T>: EuclideanLength<T>,
sourceimpl<C: CoordNum> HasDimensions for Rect<C>
impl<C: CoordNum> HasDimensions for Rect<C>
sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Some geometries, like a MultiPoint
, can have zero coordinates - we call these empty
. Read more
sourcefn dimensions(&self) -> Dimensions
fn dimensions(&self) -> Dimensions
The dimensions of some geometries are fixed, e.g. a Point always has 0 dimensions. However
for others, the dimensionality depends on the specific geometry instance - for example
typical Rect
s are 2-dimensional, but it’s possible to create degenerate Rect
s which
have either 1 or 0 dimensions. Read more
sourcefn boundary_dimensions(&self) -> Dimensions
fn boundary_dimensions(&self) -> Dimensions
The dimensions of the Geometry
’s boundary, as used by OGC-SFA. Read more
sourceimpl<T> Intersects<Coordinate<T>> for Rect<T> where
T: CoordNum,
impl<T> Intersects<Coordinate<T>> for Rect<T> where
T: CoordNum,
fn intersects(&self, rhs: &Coordinate<T>) -> bool
sourceimpl<T> Intersects<Geometry<T>> for Rect<T> where
Geometry<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Geometry<T>> for Rect<T> where
Geometry<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Geometry<T>) -> bool
sourceimpl<T> Intersects<GeometryCollection<T>> for Rect<T> where
GeometryCollection<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<GeometryCollection<T>> for Rect<T> where
GeometryCollection<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &GeometryCollection<T>) -> bool
sourceimpl<T> Intersects<Line<T>> for Rect<T> where
T: GeoNum,
impl<T> Intersects<Line<T>> for Rect<T> where
T: GeoNum,
fn intersects(&self, rhs: &Line<T>) -> bool
sourceimpl<T> Intersects<LineString<T>> for Rect<T> where
LineString<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<LineString<T>> for Rect<T> where
LineString<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &LineString<T>) -> bool
sourceimpl<T> Intersects<MultiLineString<T>> for Rect<T> where
MultiLineString<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<MultiLineString<T>> for Rect<T> where
MultiLineString<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiLineString<T>) -> bool
sourceimpl<T> Intersects<MultiPoint<T>> for Rect<T> where
MultiPoint<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<MultiPoint<T>> for Rect<T> where
MultiPoint<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPoint<T>) -> bool
sourceimpl<T> Intersects<MultiPolygon<T>> for Rect<T> where
MultiPolygon<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<MultiPolygon<T>> for Rect<T> where
MultiPolygon<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &MultiPolygon<T>) -> bool
sourceimpl<T> Intersects<Point<T>> for Rect<T> where
Point<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Point<T>> for Rect<T> where
Point<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Point<T>) -> bool
sourceimpl<T> Intersects<Polygon<T>> for Rect<T> where
Polygon<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Polygon<T>> for Rect<T> where
Polygon<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Polygon<T>) -> bool
sourceimpl<T> Intersects<Rect<T>> for Polygon<T> where
T: GeoNum,
impl<T> Intersects<Rect<T>> for Polygon<T> where
T: GeoNum,
fn intersects(&self, rect: &Rect<T>) -> bool
sourceimpl<T> Intersects<Rect<T>> for Coordinate<T> where
Rect<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Rect<T>> for Coordinate<T> where
Rect<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Rect<T>) -> bool
sourceimpl<T> Intersects<Rect<T>> for Rect<T> where
T: CoordNum,
impl<T> Intersects<Rect<T>> for Rect<T> where
T: CoordNum,
fn intersects(&self, other: &Rect<T>) -> bool
sourceimpl<T> Intersects<Rect<T>> for Line<T> where
Rect<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Rect<T>> for Line<T> where
Rect<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Rect<T>) -> bool
sourceimpl<T> Intersects<Triangle<T>> for Rect<T> where
Triangle<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Rect<T> where
Triangle<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
sourceimpl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Rect<T>
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Rect<T>
type Output = Rect<NT>
sourcefn map_coords(
&self,
func: impl Fn(Coordinate<T>) -> Coordinate<NT> + Copy
) -> Self::Output
fn map_coords(
&self,
func: impl Fn(Coordinate<T>) -> Coordinate<NT> + Copy
) -> Self::Output
Apply a function to all the coordinates in a geometric object, returning a new object. Read more
sourcefn try_map_coords<E>(
&self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<NT>, E>
) -> Result<Self::Output, E>
fn try_map_coords<E>(
&self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<NT>, E>
) -> Result<Self::Output, E>
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
sourceimpl<T: CoordNum> MapCoordsInPlace<T> for Rect<T>
impl<T: CoordNum> MapCoordsInPlace<T> for Rect<T>
sourcefn map_coords_in_place(&mut self, func: impl Fn(Coordinate<T>) -> Coordinate<T>)
fn map_coords_in_place(&mut self, func: impl Fn(Coordinate<T>) -> Coordinate<T>)
Apply a function to all the coordinates in a geometric object, in place Read more
sourcefn try_map_coords_in_place<E>(
&mut self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<T>, E>
) -> Result<(), E>
fn try_map_coords_in_place<E>(
&mut self,
func: impl Fn(Coordinate<T>) -> Result<Coordinate<T>, E>
) -> Result<(), E>
Map a fallible function over all the coordinates in a geometry, in place, returning a Result
. Read more
sourceimpl<T: CoordNum> MapCoordsInplace<T> for Rect<T>
impl<T: CoordNum> MapCoordsInplace<T> for Rect<T>
sourcefn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy) where
T: CoordNum,
👎 Deprecated since 0.21.0: use MapCoordsInPlace::map_coords_in_place
instead which takes a Coordinate
instead of an (x,y) tuple
fn map_coords_inplace(&mut self, func: impl Fn((T, T)) -> (T, T) + Copy) where
T: CoordNum,
use MapCoordsInPlace::map_coords_in_place
instead which takes a Coordinate
instead of an (x,y) tuple
Apply a function to all the coordinates in a geometric object, in place
Examples
#[allow(deprecated)]
use geo::MapCoordsInplace;
use geo::Point;
use approx::assert_relative_eq;
let mut p = Point::new(10., 20.);
#[allow(deprecated)]
p.map_coords_inplace(|(x, y)| (x + 1000., y * 2.));
assert_relative_eq!(p, Point::new(1010., 40.), epsilon = 1e-6);
sourceimpl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Rect<F>
fn relate(&self, other: &GeometryCollection<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Line<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, Line<F>> for Rect<F>
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, LineString<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, LineString<F>> for Rect<F>
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiLineString<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, MultiLineString<F>> for Rect<F>
fn relate(&self, other: &MultiLineString<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiPoint<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, MultiPoint<F>> for Rect<F>
fn relate(&self, other: &MultiPoint<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Rect<F>
fn relate(&self, other: &MultiPolygon<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Point<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, Point<F>> for Rect<F>
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Polygon<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, Polygon<F>> for Rect<F>
fn relate(&self, other: &Polygon<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for Point<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for Point<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for Line<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for Line<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for LineString<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for LineString<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for Polygon<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for Polygon<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for MultiPoint<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for MultiPoint<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for MultiLineString<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for MultiLineString<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for MultiPolygon<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for MultiPolygon<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for Rect<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for Triangle<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for Triangle<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Rect<F>> for GeometryCollection<F>
impl<F: GeoFloat> Relate<F, Rect<F>> for GeometryCollection<F>
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
sourceimpl<F: GeoFloat> Relate<F, Triangle<F>> for Rect<F>
impl<F: GeoFloat> Relate<F, Triangle<F>> for Rect<F>
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
sourceimpl<T> RelativeEq<Rect<T>> for Rect<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
impl<T> RelativeEq<Rect<T>> for Rect<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
sourcefn relative_eq(
&self,
other: &Rect<T>,
epsilon: <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon,
max_relative: <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Rect<T>,
epsilon: <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon,
max_relative: <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
) -> bool
Equality assertion within a relative limit.
Examples
use geo_types::Rect;
let a = Rect::new((0.0, 0.0), (10.0, 10.0));
let b = Rect::new((0.0, 0.0), (10.01, 10.0));
approx::assert_relative_eq!(a, b, max_relative=0.1);
approx::assert_relative_ne!(a, b, max_relative=0.0001);
sourcefn default_max_relative() -> <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
fn default_max_relative() -> <Rect<T> as AbsDiffEq<Rect<T>>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of [RelativeEq::relative_eq
].
sourceimpl<T> TryFrom<Geometry<T>> for Rect<T> where
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for Rect<T> where
T: CoordNum,
Convert a Geometry enum into its inner type.
Fails if the enum case does not match the type you are trying to convert it to.
sourceimpl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for Rect<T>
impl<T: CoordNum, NT: CoordNum, E> TryMapCoords<T, NT, E> for Rect<T>
type Output = Rect<NT>
type Output = Rect<NT>
use MapCoords::try_map_coords
which takes a Coordinate
instead of an (x,y) tuple
sourcefn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
fn try_map_coords(
&self,
func: impl Fn((T, T)) -> Result<(NT, NT), E> + Copy
) -> Result<Self::Output, E>
use MapCoords::try_map_coords
which takes a Coordinate
instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, returning a Result Read more
sourceimpl<T: CoordNum, E> TryMapCoordsInplace<T, E> for Rect<T>
impl<T: CoordNum, E> TryMapCoordsInplace<T, E> for Rect<T>
sourcefn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
fn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>
use MapCoordsInPlace::try_map_coords_in_place
which takes a Coordinate
instead of an (x,y) tuple
Map a fallible function over all the coordinates in a geometry, in place, returning a Result
. Read more
impl<T> Copy for Rect<T> where
T: Copy + CoordNum,
impl<T> Eq for Rect<T> where
T: Eq + CoordNum,
impl<T> StructuralEq for Rect<T> where
T: CoordNum,
impl<T> StructuralPartialEq for Rect<T> where
T: CoordNum,
Auto Trait Implementations
impl<T> RefUnwindSafe for Rect<T> where
T: RefUnwindSafe,
impl<T> Send for Rect<T> where
T: Send,
impl<T> Sync for Rect<T> where
T: Sync,
impl<T> Unpin for Rect<T> where
T: Unpin,
impl<T> UnwindSafe for Rect<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<G, T, U> Convert<T, U> for G where
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
impl<G, T, U> Convert<T, U> for G where
T: CoordNum,
U: CoordNum + From<T>,
G: MapCoords<T, U>,
sourceimpl<'a, T, G> Extremes<'a, T> for G where
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
impl<'a, T, G> Extremes<'a, T> for G where
G: CoordsIter<'a, Scalar = T>,
T: CoordNum,
sourceimpl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
impl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
sourcefn rotate_around_point(&self, angle: T, point: Point<T>) -> G
fn rotate_around_point(&self, angle: T, point: Point<T>) -> G
Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more
sourceimpl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,
impl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInPlace<T>,
sourcefn translate(&self, xoff: T, yoff: T) -> G
fn translate(&self, xoff: T, yoff: T) -> G
Translate a Geometry along its axes by the given offsets Read more
sourcefn translate_in_place(&mut self, xoff: T, yoff: T)
fn translate_in_place(&mut self, xoff: T, yoff: T)
Translate a Geometry along its axes, but in place.
sourcefn translate_inplace(&mut self, xoff: T, yoff: T)
fn translate_inplace(&mut self, xoff: T, yoff: T)
renamed to translate_in_place
Translate a Geometry along its axes, but in place.