Skip to content

Commit

Permalink
Better definition for diameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Oct 30, 2012
1 parent 357a025 commit 0681b24
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Diagrams/Core/Envelope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ envelopeP v = P . envelopeV v
-- | Compute the diameter of a enveloped object along a particular
-- vector. Returns zero for the empty envelope.
diameter :: Enveloped a => V a -> a -> Scalar (V a)
diameter v a = magnitude (envelopeV v a ^-^ envelopeV (negateV v) a)
diameter v a = case appEnvelope $ getEnvelope a of
(Just env) -> (env v - env (negateV v)) * magnitude v
Nothing -> 0

-- | Compute the \"radius\" (1\/2 the diameter) of an enveloped object
-- along a particular vector.
Expand Down

0 comments on commit 0681b24

Please sign in to comment.