-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example where offsetTrail does not work as expected #118
Comments
More exploration: {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
import Diagrams.Backend.SVG.CmdLine
import Diagrams.Prelude
import Diagrams.Tangent
import Diagrams.TwoD.Offset
pts = map p2 [(0,0), (2,3), (5,-2), (-4,1), (0,3)]
s :: Located (Trail R2)
s = cubicSpline False pts
segs :: [Located (Segment Closed R2)]
segs = locatedTrailSegments s
segs' :: [Located (Trail R2)]
segs' = map (bindLoc (offsetSegment stdTolerance 1)) segs
dia = (mconcat . map strokeLocTrail $ segs') <> strokeLocTrail s
main = defaultMain (dia # lw 0.05)
locatedTrailSegments :: (InnerSpace v, OrderedField (Scalar v))
=> Located (Trail v) -> [Located (Segment Closed v)]
locatedTrailSegments t = zipWith at (trailSegments (unLoc t)) (trailVertices t)
bindLoc :: (Transformable b, V a ~ V b) => (a -> b) -> Located a -> b
bindLoc f = join' . mapLoc f
where
join' (viewLoc -> (p,a)) = translate (p .-. origin) a |
There are several bad things going on here. The long lines are due to the trace giving a bogus intersection that is clearly beyond the limit of possible intersections. It is doing this because it is given nearly identical lines because |
The default epsilon given is too small. I think we need to make epsilon relative to the given radius. Any thoughts? |
Whatever works. I don't have a good sense of what the "right thing" to do is. |
I did not mean to close the issue -- just mention it. The epsilon issue is addressed, but what still remains is when offset segments that are nearly parallel are joined we get bogus miter join points. |
I was hoping that switching to a more common definition of miter limit, but that has some numerical instability in another direction. I will have to look into getting intersections with (of just lines) with some error bound so we can solve this better. |
stroking
![tangent](https://camo.githubusercontent.com/4c367527d3044aab3758c60c0b7f886948efaaf19d95c5acbd3675ad9257e045/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f3533333835392f313138393032302f31636336613866632d323366622d313165332d396363322d3038393765363131616633312e706e67)
s'
results inThe text was updated successfully, but these errors were encountered: