Debian Codegraph @

src/Diagrams/TwoD/Path.hs

raw symbols SCIP
1 {-# LANGUAGE ConstraintKinds #-}
2 {-# LANGUAGE DeriveDataTypeable #-}
3 {-# LANGUAGE FlexibleContexts #-}
4 {-# LANGUAGE FlexibleInstances #-}
5 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
6 {-# LANGUAGE MultiParamTypeClasses #-}
7 {-# LANGUAGE Rank2Types #-}
8 {-# LANGUAGE StandaloneDeriving #-}
9 {-# LANGUAGE TemplateHaskell #-}
10 {-# LANGUAGE TypeFamilies #-}
11 {-# LANGUAGE TypeOperators #-}
12 {-# LANGUAGE UndecidableInstances #-}
13 {-# LANGUAGE ViewPatterns #-}
14
15 {-# OPTIONS_GHC -fno-warn-orphans #-}
16
17 -----------------------------------------------------------------------------
18 -- |
19 -- Module : Diagrams.TwoD.Path
20 -- Copyright : (c) 2011-2015 diagrams-lib team (see LICENSE)
21 -- License : BSD-style (see LICENSE)
22 -- Maintainer : [email protected]
23 --
24 -- Paths in two dimensions are special since we may stroke them to
25 -- create a 2D diagram, and (eventually) perform operations such as
26 -- intersection and union. They also have a trace, whereas paths in
27 -- higher dimensions do not.
28 --
29 -----------------------------------------------------------------------------
30
31 module Diagrams.TwoD.Path
32 ( -- * Constructing path-based diagrams
33
34 stroke, stroke'
35 , strokePath, strokeP, strokePath', strokeP'
36 , strokeTrail, strokeT, strokeTrail', strokeT'
37 , strokeLine, strokeLoop
38 , strokeLocTrail, strokeLocT, strokeLocLine, strokeLocLoop
39
40 -- ** Stroke options
41
42 , FillRule(..)
43 , getFillRule, fillRule, _fillRule
44 , StrokeOpts(..), vertexNames, queryFillRule
45
46 -- ** Inside/outside testing
47
48 , Crossings (..)
49 , isInsideWinding
50 , isInsideEvenOdd
51
52 -- * Clipping
53
54 , Clip(..), _Clip, _clip
55 , clipBy, clipTo, clipped
56
57 -- * Intersections
58
59 , intersectPoints, intersectPoints'
60 , intersectPointsP, intersectPointsP'
61 , intersectPointsT, intersectPointsT'
62 ) where
63
64 import Control.Applicative (liftA2)
65 import Control.Lens hiding (at, transform)
66 import qualified Data.Foldable as F
67 import Data.Semigroup
68 import Data.Typeable
69
70 import Data.Default
71
72 import Diagrams.Angle
73 import Diagrams.Combinators (withEnvelope, withTrace)
74 import Diagrams.Core
75 import Diagrams.Core.Trace
76 import Diagrams.Located (Located, mapLoc, unLoc)
77 import Diagrams.Parametric
78 import Diagrams.Path
79 import Diagrams.Query
80 import Diagrams.Segment
81 import Diagrams.Solve.Polynomial
82 import Diagrams.Trail
83 import Diagrams.TrailLike
84 import Diagrams.TwoD.Segment
85 import Diagrams.TwoD.Types
86 import Diagrams.TwoD.Vector
87 import Diagrams.Util (tau)
88
89 import Linear.Affine
90 import Linear.Vector
91
92 ------------------------------------------------------------
93 -- Trail and path traces ---------------------------------
94 ------------------------------------------------------------
95
96 -- Only 2D trails and paths have a trace.
97
98 -- XXX can the efficiency of this be improved? See the comment in
99 -- Diagrams.Path on the Enveloped instance for Trail.
100 instance RealFloat n => Traced (Trail V2 n) where
101 getTrace = withLine $
102 foldr
103 (\seg bds -> moveOriginBy (negated . atEnd $ seg) bds <> getTrace seg)
104 mempty
105 . lineSegments
106
107 instance RealFloat n => Traced (Path V2 n) where
108 getTrace = F.foldMap getTrace . op Path
109
110 ------------------------------------------------------------
111 -- Constructing path-based diagrams ----------------------
112 ------------------------------------------------------------
113
114 -- | Enumeration of algorithms or \"rules\" for determining which
115 -- points lie in the interior of a (possibly self-intersecting)
116 -- path.
117 data FillRule
118 = Winding -- ^ Interior points are those with a nonzero
119 -- /winding/ /number/. See
120 -- <http://en.wikipedia.org/wiki/Nonzero-rule>.
121 | EvenOdd -- ^ Interior points are those where a ray
122 -- extended infinitely in a particular direction crosses
123 -- the path an odd number of times. See
124 -- <http://en.wikipedia.org/wiki/Even-odd_rule>.
125 deriving (Show, Typeable, Eq, Ord)
126
127 instance AttributeClass FillRule
128 instance Semigroup FillRule where
129 _ <> b = b
130
131 instance Default FillRule where
132 def = Winding
133
134 -- | A record of options that control how a path is stroked.
135 -- @StrokeOpts@ is an instance of 'Default', so a @StrokeOpts@
136 -- records can be created using @'with' { ... }@ notation.
137 data StrokeOpts a
138 = StrokeOpts
139 { _vertexNames :: [[a]]
140
141 , _queryFillRule :: FillRule
142
143 }
144
145 makeLensesWith (generateSignatures .~ False $ lensRules) ''StrokeOpts
146
147 -- | Atomic names that should be assigned to the vertices of the path so that
148 -- they can be referenced later. If there are not enough names, the extra
149 -- vertices are not assigned names; if there are too many, the extra names
150 -- are ignored. Note that this is a /list of lists/ of names, since paths
151 -- can consist of multiple trails. The first list of names are assigned to
152 -- the vertices of the first trail, the second list to the second trail, and
153 -- so on.
154 --
155 -- The default value is the empty list.
156
157 vertexNames :: Lens (StrokeOpts a) (StrokeOpts a') [[a]] [[a']]
158
159 -- | The fill rule used for determining which points are inside the path.
160 -- The default is 'Winding'. NOTE: for now, this only affects the resulting
161 -- diagram's 'Query', /not/ how it will be drawn! To set the fill rule
162 -- determining how it is to be drawn, use the 'fillRule' function.
163 queryFillRule :: Lens' (StrokeOpts a) FillRule
164
165 instance Default (StrokeOpts a) where
166 def = StrokeOpts
167 { _vertexNames = []
168 , _queryFillRule = def
169 }
170
171 -- | Convert a 'ToPath' object into a diagram. The resulting diagram has the
172 -- names 0, 1, ... assigned to each of the path's vertices.
173 --
174 -- See also 'stroke'', which takes an extra options record allowing
175 -- its behaviour to be customized.
176 --
177 -- @
178 -- 'stroke' :: 'Path' 'V2' 'Double' -> 'Diagram' b
179 -- 'stroke' :: 'Located' ('Trail' 'V2' 'Double') -> 'Diagram' b
180 -- 'stroke' :: 'Located' ('Trail'' 'Loop' 'V2' 'Double') -> 'Diagram' b
181 -- 'stroke' :: 'Located' ('Trail'' 'Line' 'V2' 'Double') -> 'Diagram' b
182 -- @
183 stroke :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b)
184 => t -> QDiagram b V2 n Any
185 stroke = strokeP . toPath
186
187 -- | A variant of 'stroke' that takes an extra record of options to
188 -- customize its behaviour. In particular:
189 --
190 -- * Names can be assigned to the path's vertices
191 --
192 -- 'StrokeOpts' is an instance of 'Default', so @stroke' ('with' &
193 -- ... )@ syntax may be used.
194 stroke' :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b, IsName a)
195 => StrokeOpts a -> t -> QDiagram b V2 n Any
196 stroke' opts = strokeP' opts . toPath
197
198 -- | 'stroke' specialised to 'Path'.
199 strokeP :: (TypeableFloat n, Renderable (Path V2 n) b)
200 => Path V2 n -> QDiagram b V2 n Any
201 strokeP = strokeP' (def :: StrokeOpts ())
202
203 -- | 'stroke' specialised to 'Path'.
204 strokePath :: (TypeableFloat n, Renderable (Path V2 n) b)
205 => Path V2 n -> QDiagram b V2 n Any
206 strokePath = strokeP
207
208 instance (TypeableFloat n, Renderable (Path V2 n) b)
209 => TrailLike (QDiagram b V2 n Any) where
210 trailLike = strokeP . trailLike
211
212 -- | 'stroke'' specialised to 'Path'.
213 strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a)
214 => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any
215 strokeP' opts path
216 | null (pLines ^. _Wrapped') = mkP pLoops
217 | null (pLoops ^. _Wrapped') = mkP pLines
218 | otherwise = mkP pLines <> mkP pLoops
219 where
220 (pLines,pLoops) = partitionPath (isLine . unLoc) path
221 mkP p
222 = mkQD (Prim p)
223 (getEnvelope p)
224 (getTrace p)
225 (fromNames . concat $
226 zipWith zip (opts^.vertexNames) ((map . map) subPoint (pathVertices p))
227 )
228 (Query $ Any . (runFillRule (opts^.queryFillRule)) p)
229
230 -- | 'stroke'' specialised to 'Path'.
231 strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a)
232 => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any
233 strokePath' = strokeP'
234
235 -- | 'stroke' specialised to 'Trail'.
236 strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b)
237 => Trail V2 n -> QDiagram b V2 n Any
238 strokeTrail = stroke . pathFromTrail
239
240 -- | 'stroke' specialised to 'Trail'.
241 strokeT :: (TypeableFloat n, Renderable (Path V2 n) b)
242 => Trail V2 n -> QDiagram b V2 n Any
243 strokeT = strokeTrail
244
245 -- | A composition of 'stroke'' and 'pathFromTrail' for conveniently
246 -- converting a trail directly into a diagram.
247 strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a)
248 => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any
249 strokeTrail' opts = stroke' opts . pathFromTrail
250
251 -- | Deprecated synonym for 'strokeTrail''.
252 strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a)
253 => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any
254 strokeT' = strokeTrail'
255
256 -- | A composition of 'strokeT' and 'wrapLine' for conveniently
257 -- converting a line directly into a diagram.
258 strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b)
259 => Trail' Line V2 n -> QDiagram b V2 n Any
260 strokeLine = strokeT . wrapLine
261
262 -- | A composition of 'strokeT' and 'wrapLoop' for conveniently
263 -- converting a loop directly into a diagram.
264 strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b)
265 => Trail' Loop V2 n -> QDiagram b V2 n Any
266 strokeLoop = strokeT . wrapLoop
267
268 -- | A convenience function for converting a @Located Trail@ directly
269 -- into a diagram; @strokeLocTrail = stroke . trailLike@.
270 strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b)
271 => Located (Trail V2 n) -> QDiagram b V2 n Any
272 strokeLocTrail = strokeP . trailLike
273
274 -- | Deprecated synonym for 'strokeLocTrail'.
275 strokeLocT :: (TypeableFloat n, Renderable (Path V2 n) b)
276 => Located (Trail V2 n) -> QDiagram b V2 n Any
277 strokeLocT = strokeLocTrail
278
279 -- | A convenience function for converting a @Located@ line directly
280 -- into a diagram; @strokeLocLine = stroke . trailLike . mapLoc wrapLine@.
281 strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b)
282 => Located (Trail' Line V2 n) -> QDiagram b V2 n Any
283 strokeLocLine = strokeP . trailLike . mapLoc wrapLine
284
285 -- | A convenience function for converting a @Located@ loop directly
286 -- into a diagram; @strokeLocLoop = stroke . trailLike . mapLoc wrapLoop@.
287 strokeLocLoop :: (TypeableFloat n, Renderable (Path V2 n) b)
288 => Located (Trail' Loop V2 n) -> QDiagram b V2 n Any
289 strokeLocLoop = strokeP . trailLike . mapLoc wrapLoop
290
291 ------------------------------------------------------------
292 -- Inside/outside testing
293 ------------------------------------------------------------
294
295 runFillRule :: RealFloat n => FillRule -> Path V2 n -> Point V2 n -> Bool
296 runFillRule Winding = isInsideWinding
297 runFillRule EvenOdd = isInsideEvenOdd
298
299 -- | Extract the fill rule from a 'FillRuleA' attribute.
300 getFillRule :: FillRule -> FillRule
301 getFillRule = id
302
303 -- | Specify the fill rule that should be used for determining which
304 -- points are inside a path.
305 fillRule :: HasStyle a => FillRule -> a -> a
306 fillRule = applyAttr
307
308 -- | Lens onto the fill rule of a style.
309 _fillRule :: Lens' (Style V2 n) FillRule
310 _fillRule = atAttr . non def
311
312 -- | The sum of /signed/ crossings of a path as we travel in the
313 -- positive x direction from a given point.
314 --
315 -- - A point is filled according to the 'Winding' fill rule, if the
316 -- number of 'Crossings' is non-zero (see 'isInsideWinding').
317 --
318 -- - A point is filled according to the 'EvenOdd' fill rule, if the
319 -- number of 'Crossings' is odd (see 'isInsideEvenOdd').
320 --
321 -- This is the 'HasQuery' result for 'Path's, 'Located' 'Trail's and
322 -- 'Located' 'Loops'.
323 --
324 -- @
325 -- 'sample' :: 'Path' 'V2' 'Double' -> 'Point' 'V2' 'Double' -> 'Crossings'
326 -- 'sample' :: 'Located' ('Trail' 'V2' 'Double') -> 'Point' 'V2' 'Double' -> 'Crossings'
327 -- 'sample' :: 'Located' ('Trail'' 'Loop' 'V2' 'Double') -> 'Point' 'V2' 'Double' -> 'Crossings'
328 -- @
329 --
330 -- Note that 'Line's have no inside or outside, so don't contribute
331 -- crossings
332 newtype Crossings = Crossings Int
333 deriving (Show, Eq, Ord, Num, Enum, Real, Integral)
334
335 instance Semigroup Crossings where
336 Crossings a <> Crossings b = Crossings (a + b)
337
338 instance Monoid Crossings where
339 mempty = Crossings 0
340 mappend = (<>)
341
342 instance RealFloat n => HasQuery (Located (Trail V2 n)) Crossings where
343 getQuery trail = Query $ \p -> trailCrossings p trail
344
345 instance RealFloat n => HasQuery (Located (Trail' l V2 n)) Crossings where
346 getQuery trail' = getQuery (mapLoc Trail trail')
347
348 instance RealFloat n => HasQuery (Path V2 n) Crossings where
349 getQuery = foldMapOf each getQuery
350
351 -- | Test whether the given point is inside the given path,
352 -- by testing whether the point's /winding number/ is nonzero. Note
353 -- that @False@ is /always/ returned for paths consisting of lines
354 -- (as opposed to loops), regardless of the winding number.
355 --
356 -- @
357 -- 'isInsideWinding' :: 'Path' 'V2' 'Double' -> 'Point' 'V2' 'Double' -> 'Bool'
358 -- 'isInsideWinding' :: 'Located' ('Trail' 'V2' 'Double') -> 'Point' 'V2' 'Double' -> 'Bool'
359 -- 'isInsideWinding' :: 'Located' ('Trail'' 'Loop' 'V2' 'Double') -> 'Point' 'V2' 'Double' -> 'Bool'
360 -- @
361 isInsideWinding :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool
362 isInsideWinding t = (/= 0) . sample t
363
364 -- | Test whether the given point is inside the given path,
365 -- by testing whether a ray extending from the point in the positive
366 -- x direction crosses the path an even (outside) or odd (inside)
367 -- number of times. Note that @False@ is /always/ returned for
368 -- paths consisting of lines (as opposed to loops), regardless of
369 -- the number of crossings.
370 --
371 -- @
372 -- 'isInsideEvenOdd' :: 'Path' 'V2' 'Double' -> 'Point' 'V2' 'Double' -> 'Bool'
373 -- 'isInsideEvenOdd' :: 'Located' ('Trail' 'V2' 'Double') -> 'Point' 'V2' 'Double' -> 'Bool'
374 -- 'isInsideEvenOdd' :: 'Located' ('Trail'' 'Loop' 'V2' 'Double') -> 'Point' 'V2' 'Double' -> 'Bool'
375 -- @
376 isInsideEvenOdd :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool
377 isInsideEvenOdd t = odd . sample t
378
379 -- | Compute the sum of signed crossings of a trail starting from the
380 -- given point in the positive x direction.
381 trailCrossings :: RealFloat n => Point V2 n -> Located (Trail V2 n) -> Crossings
382
383 -- non-loop trails have no inside or outside, so don't contribute crossings
384 trailCrossings _ t | not (isLoop (unLoc t)) = 0
385
386 trailCrossings p@(unp2 -> (x,y)) tr
387 = F.foldMap test $ fixTrail tr
388 where
389 test (FLinear a@(unp2 -> (_,ay)) b@(unp2 -> (_,by)))
390 | ay <= y && by > y && isLeft a b > 0 = 1
391 | by <= y && ay > y && isLeft a b < 0 = -1
392 | otherwise = 0
393
394 test c@(FCubic (P x1@(V2 _ x1y))
395 (P c1@(V2 _ c1y))
396 (P c2@(V2 _ c2y))
397 (P x2@(V2 _ x2y))
398 ) =
399 sum . map testT $ ts
400 where ts = filter (liftA2 (&&) (>=0) (<=1))
401 $ cubForm (- x1y + 3*c1y - 3*c2y + x2y)
402 ( 3*x1y - 6*c1y + 3*c2y)
403 (-3*x1y + 3*c1y)
404 (x1y - y)
405 testT t = let (unp2 -> (px,_)) = c `atParam` t
406 in if px > x then signFromDerivAt t else 0
407 signFromDerivAt t =
408 let v = (3*t*t) *^ ((-1)*^x1 ^+^ 3*^c1 ^-^ 3*^c2 ^+^ x2)
409 ^+^ (2*t) *^ (3*^x1 ^-^ 6*^c1 ^+^ 3*^c2)
410 ^+^ ((-3)*^x1 ^+^ 3*^c1)
411 ang = v ^. _theta . rad
412 in case () of _ | 0 < ang && ang < tau/2 && t < 1 -> 1
413 | -tau/2 < ang && ang < 0 && t > 0 -> -1
414 | otherwise -> 0
415
416 isLeft a b = cross2 (b .-. a) (p .-. a)
417
418 ------------------------------------------------------------
419 -- Clipping ----------------------------------------------
420 ------------------------------------------------------------
421
422 -- | @Clip@ tracks the accumulated clipping paths applied to a
423 -- diagram. Note that the semigroup structure on @Clip@ is list
424 -- concatenation, so applying multiple clipping paths is sensible.
425 -- The clipping region is the intersection of all the applied
426 -- clipping paths.
427 newtype Clip n = Clip [Path V2 n]
428 deriving (Typeable, Semigroup)
429
430 makeWrapped ''Clip
431
432 instance Typeable n => AttributeClass (Clip n)
433
434 instance AsEmpty (Clip n) where
435 _Empty = _Clip . _Empty
436
437 type instance V (Clip n) = V2
438 type instance N (Clip n) = n
439
440 instance (OrderedField n) => Transformable (Clip n) where
441 transform t (Clip ps) = Clip (transform t ps)
442
443 -- | A point inside a clip if the point is in 'All' invididual clipping
444 -- paths.
445 instance RealFloat n => HasQuery (Clip n) All where
446 getQuery (Clip paths) = Query $ \p ->
447 F.foldMap (All . flip isInsideWinding p) paths
448
449 _Clip :: Iso (Clip n) (Clip n') [Path V2 n] [Path V2 n']
450 _Clip = _Wrapped
451
452 -- | Lens onto the Clip in a style. An empty list means no clipping.
453 _clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n]
454 _clip = atTAttr . non' _Empty . _Clip
455
456 -- | Clip a diagram by the given path:
457 --
458 -- * Only the parts of the diagram which lie in the interior of the
459 -- path will be drawn.
460 --
461 -- * The envelope of the diagram is unaffected.
462 clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> a -> a
463 clipBy = applyTAttr . Clip . (:[])
464
465 -- | Clip a diagram to the given path setting its envelope to the
466 -- pointwise minimum of the envelopes of the diagram and path. The
467 -- trace consists of those parts of the original diagram's trace
468 -- which fall within the clipping path, or parts of the path's trace
469 -- within the original diagram.
470 clipTo :: TypeableFloat n
471 => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
472 clipTo p d = setTrace intersectionTrace . toEnvelope $ clipBy p d
473 where
474 envP = appEnvelope . getEnvelope $ p
475 envD = appEnvelope . getEnvelope $ d
476 toEnvelope = case (envP, envD) of
477 (Just eP, Just eD) -> setEnvelope . mkEnvelope $ \v -> min (eP v) (eD v)
478 (_, _) -> id
479 intersectionTrace = Trace traceIntersections
480 traceIntersections pt v =
481 -- on boundary of d, inside p
482 onSortedList (filter pInside) (appTrace (getTrace d) pt v) <>
483 -- or on boundary of p, inside d
484 onSortedList (filter dInside) (appTrace (getTrace p) pt v) where
485 newPt dist = pt .+^ v ^* dist
486 pInside dDist = runFillRule Winding p (newPt dDist)
487 dInside pDist = getAny . sample d $ newPt pDist
488
489 -- | Clip a diagram to the clip path taking the envelope and trace of the clip
490 -- path.
491 clipped :: TypeableFloat n
492 => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
493 clipped p = withTrace p . withEnvelope p . clipBy p
494
495 ------------------------------------------------------------
496 -- Intersections -----------------------------------------
497 ------------------------------------------------------------
498
499 -- | Find the intersect points of two objects that can be converted to a path.
500 intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n)
501 => t -> s -> [P2 n]
502 intersectPoints = intersectPoints' 1e-8
503
504 -- | Find the intersect points of two objects that can be converted to a path
505 -- within the given tolerance.
506 intersectPoints' :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n)
507 => n -> t -> s -> [P2 n]
508 intersectPoints' eps t s = intersectPointsP' eps (toPath t) (toPath s)
509
510 -- | Compute the intersect points between two paths.
511 intersectPointsP :: OrderedField n => Path V2 n -> Path V2 n -> [P2 n]
512 intersectPointsP = intersectPointsP' 1e-8
513
514 -- | Compute the intersect points between two paths within given tolerance.
515 intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n]
516 intersectPointsP' eps as bs = do
517 a <- pathTrails as
518 b <- pathTrails bs
519 intersectPointsT' eps a b
520
521 -- | Compute the intersect points between two located trails.
522 intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]
523 intersectPointsT = intersectPointsT' 1e-8
524
525 -- | Compute the intersect points between two located trails within the given
526 -- tolerance.
527 intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]
528 intersectPointsT' eps as bs = do
529 a <- fixTrail as
530 b <- fixTrail bs
531 intersectPointsS' eps a b