d6fa2f0b7f60eda2cbe068df73746f41b280b8e2
3 open System.Diagnostics
7 let roundInt = int << round
9 let inline dprintfn fmt
=
10 Printf.ksprintf
System.Diagnostics.Debug.WriteLine fmt
12 let mutable log : (string -> unit) =
15 let logTime (m
: string) (f
: unit -> 'a) : 'a
=
20 log <| sprintf "%A (time: %A ms)" m
sw.ElapsedMilliseconds
23 let inline lineFromTwoPoints
(p1
: PointD) (p2
: PointD) : Line =
24 let a = (p1
.Y - p2
.Y) / (p1
.X - p2
.X)
25 let b = -(p2
.X * p1
.Y - p1
.X * p2
.Y) / (p1
.X - p2
.X)
28 let inline pointFromTwoLines
(l1
: Line) (l2
: Line) : PointD =
29 let x = -(l1
.B - l2
.B) / (l1
.A - l2
.A)
30 let y = -(l2
.A * l1
.B - l1
.A * l2
.B) / (l1
.A - l2
.A)
33 let inline squaredDistanceTwoPoints
(p1
: PointD) (p2
: PointD) =
34 (p1
.X - p2
.X) ** 2.0 + (p1
.Y - p2
.Y) ** 2.0
36 let distanceTwoPoints (p1
: PointD) (p2
: PointD) =
37 squaredDistanceTwoPoints
p1 p2
|> sqrt
39 let countCells (cells
: Cell list) : int * int =
40 cells
|> List.fold
(fun (total
, infected
) { cellClass
= cellClass
} ->
42 | HealthyRBC -> (total
+ 1, infected
)
43 | InfectedRBC -> (total
+ 1, infected
+ 1)
44 | Peculiar -> (total
, infected
)) (0, 0)