Skip to content

Commit

Permalink
Merge pull request #225 from diagrams/linear-update
Browse files Browse the repository at this point in the history
Linear update
  • Loading branch information
cchalmers committed Nov 3, 2014
2 parents a90b1cc + d151832 commit 4fe1745
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions diagrams-lib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ Library
data-default-class < 0.1,
fingertree >= 0.1 && < 0.2,
intervals >= 0.7 && < 0.8,
lens >= 4.0 && < 4.5,
lens >= 4.0 && < 4.6,
tagged >= 0.7,
optparse-applicative >= 0.11 && < 0.12,
filepath,
JuicyPixels >= 3.1.5 && < 3.2,
hashable >= 1.1 && < 1.3,
linear >= 1.10 && < 1.11,
linear >= 1.11.3 && < 1.12,
adjunctions >= 4.0 && < 5.0,
distributive >=0.2.2 && < 1.0,
process >= 1.1 && < 1.3,
Expand Down
5 changes: 2 additions & 3 deletions src/Diagrams/Align.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module Diagrams.Align
) where

import Diagrams.Core
import Diagrams.Core.Transform
import Diagrams.Util (applyAll)

import Data.Maybe (fromMaybe)
Expand Down Expand Up @@ -153,7 +152,7 @@ centerV v = alignBy v 0
center :: (InSpace v n a, Fractional n, Traversable v, Alignable a, HasOrigin a) => a -> a
center = applyAll fs
where
fs = map centerV basis'
fs = map centerV basis

-- | Like @centerV@ using trace.
snugCenterV
Expand All @@ -166,7 +165,7 @@ snugCenter :: (InSpace v n a, Traversable v, Fractional n, Alignable a, HasOrigi
=> a -> a
snugCenter = applyAll fs
where
fs = map snugCenterV basis'
fs = map snugCenterV basis

{-# ANN module ("HLint: ignore Use camelCase" :: String) #-}

10 changes: 1 addition & 9 deletions src/Diagrams/Points.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@ module Diagrams.Points
-- * Point-related utilities
, centroid
, pointDiagram
, _pIso, lensP
, _Point, lensP
, project
) where

import Diagrams.Core (pointDiagram)
import Diagrams.Core.Points

import Control.Lens (Iso', iso)
import Data.Foldable as F

import Linear.Affine
import Linear.Metric
import Linear.Vector

-- Point v <-> v
_pIso :: Iso' (Point v n) (v n)
_pIso = iso (\(P a) -> a) P

-- | The centroid of a set of /n/ points is their sum divided by /n/.
centroid :: (Additive v, Fractional n) => [Point v n] -> Point v n
centroid = meanV
Expand All @@ -43,6 +38,3 @@ meanV :: (Foldable f, Additive v, Fractional a) => f (v a) -> v a
meanV = uncurry (^/) . F.foldl' (\(s,c) e -> (e ^+^ s,c+1)) (zero,0)
{-# INLINE meanV #-}

-- | @project u v@ computes the projection of @v@ onto @u@.
project :: (Metric v, Fractional n) => v n -> v n -> v n
project u v = ((v `dot` u) / quadrance u) *^ u
2 changes: 1 addition & 1 deletion src/Diagrams/TwoD/Polygons.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import Diagrams.Angle
import Diagrams.Core
import Diagrams.Located
import Diagrams.Path
import Diagrams.Points (centroid, project)
import Diagrams.Points (centroid)
import Diagrams.Trail
import Diagrams.TrailLike
import Diagrams.TwoD.Transform
Expand Down

0 comments on commit 4fe1745

Please sign in to comment.