Trait geo::algorithm::is_convex::IsConvex [−][src]
pub trait IsConvex {
fn convex_orientation(
&self,
allow_collinear: bool,
specific_orientation: Option<Orientation>
) -> Option<Orientation>;
fn is_collinear(&self) -> bool;
fn is_convex(&self) -> bool { ... }
fn is_ccw_convex(&self) -> bool { ... }
fn is_cw_convex(&self) -> bool { ... }
fn is_strictly_convex(&self) -> bool { ... }
fn is_strictly_ccw_convex(&self) -> bool { ... }
fn is_strictly_cw_convex(&self) -> bool { ... }
}
Expand description
Predicates to test the convexity of a LineString
.
A closed LineString
is said to be convex if it
encloses a convex set. It is said to be strictly
convex if in addition, no three consecutive vertices
are collinear. It is collinear if all the vertices lie
on the same line.
Remarks
-
Collinearity does not require that the
LineString
be closed, but the rest of the predicates do. -
This definition is closely related to the notion of convexity of polygons. In particular, a
Polygon
is convex, if and only if itsexterior
is convex, andinteriors
is empty. -
The
ConvexHull
algorithm always returns a strictly convexLineString
unless the input is empty or collinear. Thegraham_hull
algorithm provides an option to include collinear points, producing a (possibly non-strict) convexLineString
.
Edge Cases
-
the convexity, and collinearity of an empty
LineString
is unspecified and must not be relied upon. -
A closed
LineString
with at most three coordinates (including the possibly repeated first coordinate) is both convex and collinear. However, the strict convexity is unspecified and must not be relied upon.
Required methods
fn convex_orientation(
&self,
allow_collinear: bool,
specific_orientation: Option<Orientation>
) -> Option<Orientation>
fn convex_orientation(
&self,
allow_collinear: bool,
specific_orientation: Option<Orientation>
) -> Option<Orientation>
Test and get the orientation if the shape is convex.
Tests for strict convexity if allow_collinear
, and
only accepts a specific orientation if provided.
The return value is None
if either:
-
the shape is not convex
-
the shape is not strictly convex, and
allow_collinear
is false -
an orientation is specified, and some three consecutive vertices where neither collinear, nor in the specified orientation.
In all other cases, the return value is the
orientation of the shape, or Orientation::Collinear
if all the vertices are on the same line.
Note. This predicate is not equivalent to
is_collinear
as this requires that the input is
closed.
fn is_collinear(&self) -> bool
fn is_collinear(&self) -> bool
Test if the shape lies on a line.
Provided methods
fn is_ccw_convex(&self) -> bool
fn is_ccw_convex(&self) -> bool
Test if the shape is convex, and oriented counter-clockwise.
fn is_cw_convex(&self) -> bool
fn is_cw_convex(&self) -> bool
Test if the shape is convex, and oriented clockwise.
fn is_strictly_convex(&self) -> bool
fn is_strictly_convex(&self) -> bool
Test if the shape is strictly convex.
fn is_strictly_ccw_convex(&self) -> bool
fn is_strictly_ccw_convex(&self) -> bool
Test if the shape is strictly convex, and oriented counter-clockwise.
fn is_strictly_cw_convex(&self) -> bool
fn is_strictly_cw_convex(&self) -> bool
Test if the shape is strictly convex, and oriented clockwise.