module Geom2D.CubicBezier.Outline
(bezierOffset, bezierOffsetMax)
where
import Geom2D
import Geom2D.CubicBezier.Basic
import Geom2D.CubicBezier.Approximate
import Geom2D.CubicBezier.Curvature
offsetPoint :: Double -> Point -> Point -> Point
offsetPoint dist start tangent =
start ^+^ (rotate90L $* dist *^ normVector tangent)
bezierOffsetPoint :: CubicBezier -> Double -> Double -> (Point, Point)
bezierOffsetPoint cb dist t = (offsetPoint dist p p', p')
where (p, p') = evalBezierDeriv cb t
offsetSegment :: Double -> Double -> CubicBezier -> [CubicBezier]
offsetSegment dist tol cb =
approximatePath (bezierOffsetPoint cb dist) 15 tol 0 1
offsetSegmentMax :: Int -> Double -> Double -> CubicBezier -> [CubicBezier]
offsetSegmentMax m dist tol cb =
approximatePathMax m (bezierOffsetPoint cb dist) 15 tol 0 1
bezierOffset :: CubicBezier
-> Double
-> Double
-> [CubicBezier]
bezierOffset cb dist tol =
concatMap (offsetSegment dist tol) $
splitBezierN cb $
findRadius cb dist tol
bezierOffsetMax :: Int -> CubicBezier -> Double -> Double -> [CubicBezier]
bezierOffsetMax n cb dist tol =
concatMap (offsetSegmentMax n dist tol) $
splitBezierN cb $
findRadius cb dist tol