import R2Graph --------------------------------------------- -- Compute a circle inscribed in a triangle --------------------------------------------- incircle :: Triangle -> Circle incircle t = let n1 = normalize ((vertex1 t) `subtractPoints` (vertex0 t)) n2 = normalize ((vertex2 t) `subtractPoints` (vertex0 t)) b0 = n1 `addVectors` n2 n3 = normalize ((vertex2 t) `subtractPoints` (vertex1 t)) n4 = n1 `multiplyVector` (-1) b1 = n3 `addVectors` n4 bis0 = Line (vertex0 t) b0 bis1 = Line (vertex1 t) b1 (Just c) = intersectLines bis0 bis1 r = c `distanceToLine` (Line (vertex0 t) n1) in Circle c r