Skip to content

Commit

Permalink
fix for: section producing incorrect results diagrams#322
Browse files Browse the repository at this point in the history
The section instance of SegTree seems to be correct, but the
instances for Located, Trail, and Trail' Line all used the
default definition which uses splitAtParam instead of SegTree's
implementation of section. The default definition of splitAtParam
is only correct for types which consist of a single segment or are
parametrized by arclength (rather than with each segment having
equal weight).
  • Loading branch information
Mike Zuser committed Mar 7, 2019
1 parent 9febf32 commit c0da81d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Diagrams/Located.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ instance (InSpace v n a, Fractional n, Parametric a, Sectionable a, Codomain a ~
splitAtParam (Loc x a) p = (Loc x a1, Loc (x .+^ (a `atParam` p)) a2)
where (a1,a2) = splitAtParam a p

section (Loc x a) p1 p2 = Loc (x .+^ (a `atParam` p1)) (section a p1 p2)

reverseDomain (Loc x a) = Loc (x .+^ y) (reverseDomain a)
where y = a `atParam` domainUpper a

Expand Down
4 changes: 4 additions & 0 deletions src/Diagrams/Trail.hs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ instance (Metric v, OrderedField n, Real n)
where
(t1, t2) = splitAtParam t p

section (Line t) p1 p2 = Line (section t p1 p2)

reverseDomain = reverseLine

instance (Metric v, OrderedField n, Real n)
Expand Down Expand Up @@ -768,6 +770,8 @@ instance (Metric v, OrderedField n, Real n) => EndValues (Trail v n)
instance (Metric v, OrderedField n, Real n) => Sectionable (Trail v n) where
splitAtParam t p = withLine ((wrapLine *** wrapLine) . (`splitAtParam` p)) t

section t p1 p2 = withLine (wrapLine . (\l -> section l p1 p2)) t

reverseDomain = reverseTrail

instance (Metric v, OrderedField n, Real n)
Expand Down

0 comments on commit c0da81d

Please sign in to comment.