pub trait IsConvex {
    // Required methods
    fn convex_orientation(
        &self,
        allow_collinear: bool,
        specific_orientation: Option<Orientation>
    ) -> Option<Orientation>;
    fn is_collinear(&self) -> bool;

    // Provided methods
    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 its exterior is convex, and interiors is empty.

  • The ConvexHull algorithm always returns a strictly convex LineString unless the input is empty or collinear. The graham_hull algorithm provides an option to include collinear points, producing a (possibly non-strict) convex LineString.

§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§

source

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:

  1. the shape is not convex

  2. the shape is not strictly convex, and allow_collinear is false

  3. 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.

source

fn is_collinear(&self) -> bool

Test if the shape lies on a line.

Provided Methods§

source

fn is_convex(&self) -> bool

Test if the shape is convex.

source

fn is_ccw_convex(&self) -> bool

Test if the shape is convex, and oriented counter-clockwise.

source

fn is_cw_convex(&self) -> bool

Test if the shape is convex, and oriented clockwise.

source

fn is_strictly_convex(&self) -> bool

Test if the shape is strictly convex.

source

fn is_strictly_ccw_convex(&self) -> bool

Test if the shape is strictly convex, and oriented counter-clockwise.

source

fn is_strictly_cw_convex(&self) -> bool

Test if the shape is strictly convex, and oriented clockwise.

Implementors§