Closed bacchanalia closed 5 years ago
This can be fixed narrowly by changing (>=) to (>) here, but the p > 0 case is still wrong. I've eyeballed some outputs for the p < 0 and they look plausible.
The equation on line 241 looks wrong to me:
On 243, I think the lambda should be id, since the number of segments doesn't change, but that doesn't completely fix it, so maybe an issue on 241 also. https://github.com/diagrams/diagrams-lib/blob/7ff9922585df000b7be51056cf3a7c45db8c847f/src/Diagrams/Trail.hs#L243
I think 241 is more naturally expressed as 1 + (p - 1)*tsegs, but I think it's correct.
I think 243 is only id when u corresponds to a previous segment, and in the case it's on the same segment it needs to be rescaled.
Ah, yes, I was reading the code wrong. I can make sense of 241 now.
I want to rewrite sectionAtParam' for more clarity. Right now it returns ((Segtree v n, n -> n), (Segtree v n, n -> n)) but the second (n -> n) which represents the reparamaterization of the second tree is never used. Is there any reason to keep that code?
The uses I can think of would be fine with sectionAtParam'
only giving one remapping. However, having both could be nice for testing as you could check the consistency of computing section
by comparing the results from both methods:
sectionA x t1 t2 = let ((a,fa),_) = splitAtParam' x t2 in snd $ splitAtParam a (fa t1)
sectionB x t1 t2 = let (_,(b,fb)) = splitAtParam' x t1 in fst $ splitAtParam b (fb t2)
prop_section x t1 t2 = sectionA x t1 t2 =~= sectionB x t1 t2
For some appropriate =~=
.
In order to have that test we'd need to export splitAtParam', which I'm not sure is worth doing just to have that test.
Red sections should be equal to green sections.