Skip to content

Commit

Permalink
bug fix: compute diameter correctly: add scalars instead of subtracting
Browse files Browse the repository at this point in the history
Fixes #35. This one was sneaky.  The bug was introduced in
0681b24,
which looks innocuous on the surface -- but there's a big difference
between subtracting two *vectors* (what the original code did) and
subtracting two *scalars* (which is what the code does now).  What we
actually want to do is *add* the two scalars.
  • Loading branch information
Brent Yorgey committed Mar 6, 2013
1 parent c725edb commit 3555283
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Diagrams/Core/Envelope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ envelopeS v = fromMaybe 0 . envelopeSMay v
-- vector. Returns zero for the empty envelope.
diameter :: Enveloped a => V a -> a -> Scalar (V a)
diameter v a = case appEnvelope $ getEnvelope a of
(Just env) -> (env v - env (negateV v)) * magnitude v
(Just env) -> (env v + env (negateV v)) * magnitude v
Nothing -> 0

-- | Compute the \"radius\" (1\/2 the diameter) of an enveloped object
Expand Down

0 comments on commit 3555283

Please sign in to comment.