[−][src]Function fart_2d_geom::center
pub fn center<T, U>(points: &[TypedPoint2D<T, U>]) -> TypedPoint2D<T, U> where
T: Copy + NumAssign + NumCast,
Find the center (mean) of a set of points.
Panics
Will panic if the given points
is empty, or if a T
cannot be created
from points.len()
.
Example
use euclid::{point2, UnknownUnit}; use fart_2d_geom::center; let c = center::<i32, UnknownUnit>(&[ point2(0, 0), point2(2, 0), point2(0, 2), point2(2, 2), ]); assert_eq!(c, point2(1, 1));