Skip to content

Commit

Permalink
Add doc example for centroid.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jan 11, 2019
1 parent d95f564 commit bf1d361
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions geo/src/algorithm/centroid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@ use {Line, LineString, MultiPoint, MultiPolygon, Point, Polygon, Rect};
/// balanced on the tip of a pin.
/// The geometric centroid of a convex object always lies in the object.
/// A non-convex object might have a centroid that _is outside the object itself_.
///
/// # Examples
///
/// ```
/// use geo::prelude::*;
/// use geo::{LineString, Point, Polygon};
///
/// // rhombus shaped polygon
/// let polygon = Polygon::new(
/// LineString::from(vec![
/// (-2., 1.),
/// (1., 3.),
/// (4., 1.),
/// (1., -1.),
/// (-2., 1.),
/// ]),
/// vec![],
/// );
///
/// assert_eq!(
/// Point::from((1., 1.)),
/// polygon.centroid().unwrap(),
/// );
/// ```
pub trait Centroid<T: Float> {
type Output;

Expand Down

0 comments on commit bf1d361

Please sign in to comment.