packages feed

diagrams-lib-0.5.0.1 / src / Diagrams / Points.hs

{-# LANGUAGE FlexibleContexts  #-}------------------------------------------------------------------------------- |-- Module      :  Diagrams.Points-- Copyright   :  (c) 2011 diagrams-lib team (see LICENSE)-- License     :  BSD-style (see LICENSE)-- Maintainer  :  diagrams-discuss@googlegroups.com---- Some miscellaneous utilities for working with points.-------------------------------------------------------------------------------module Diagrams.Points       ( centroid       ) whereimport Graphics.Rendering.Diagramsimport Control.Newtypeimport Control.Arrow ((&&&))import Data.VectorSpace-- | The centroid of a set of /n/ points is their sum divided by /n/.centroid :: (VectorSpace v, Fractional (Scalar v)) => [Point v] -> Point vcentroid = pack . uncurry (^/) . (sumV &&& (fromIntegral . length)) . map unpack