1 module Cross(cross,overlap) where 2 import Numbers 3 import Vectors 4 import EdgePlate 5 import Solve 6 import Preds 7 import List(nub)--1.3 8 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 -- section 6: Crossing edges (MR was: lines) 10 11 -- cross yields the list of crosspoints of two edges (0 or 1 cross) 12 -- s(l)+lambda* h(l) = s(k)+mu*h(k) => s(l)-s(k) = lambda*(-h(l))+mu*h(k) 13 14 cross :: Edge -> Edge -> [(Vector,Vector)] 15 cross l k = [(s(l) + lambda`mulv`h(l), s(k) + mu`mulv`h(k)) 16 |(lambda,mu) <- solve (-h l) (h k) (s l - s k) 17 ,0 <= lambda && lambda <= 1 && 0 <= mu && mu <= 1] 18 19 -- overlap computes the important points on the border of plate ls 20 -- that are inside ks (and of course also inside ls) 21 overlap :: Plate -> Plate -> [Vector] 22 overlap (Plt _ ls) p2@(Plt _ ks)= nub ([s(l)| l<-ls, s(l)`into` p2] ++ 23 [p| l<-ls, k<-ks , (p,q)<-cross l k] )