Correctly intersect lines and circles
This commit is contained in:
@@ -251,10 +251,16 @@ orthogonalPointOnSeg a b p
|
||||
| otherwise = Just $ a +.+ param *.* (normalizeV $ b -.- a)
|
||||
where
|
||||
param = closestPointOnLineParam a b p
|
||||
|
||||
inSegArea :: Point2 -> Point2 -> Point2 -> Bool
|
||||
inSegArea a b c = param >= 0 && param <= dotV (b -.- a) (b -.- a)
|
||||
where
|
||||
param = dotV (b -.- a) (c -.- a)
|
||||
|
||||
intersectCircSeg :: Point2 -> Float -> Point2 -> Point2 -> [Point2]
|
||||
intersectCircSeg c r a b
|
||||
| y < 0 = []
|
||||
| otherwise = nub $ filter ( (< dist a b) . dist a ) [ d -.- v, d +.+ c ]
|
||||
| otherwise = nub $ filter (inSegArea a b) [ d -.- v, d +.+ c ]
|
||||
where
|
||||
d = closestPointOnLine a b c
|
||||
x = dist d c
|
||||
|
||||
Reference in New Issue
Block a user