1
module ParasitemiaCore.Utils
8 let inline roundInt
v = v |> round
|> int
10 let inline dprintfn fmt
=
11 Printf.ksprintf
System.Diagnostics.Debug.WriteLine fmt
13 let inline lineFromTwoPoints
(p1
: PointF) (p2
: PointF) : Line =
14 let a = (p1
.Y - p2
.Y) / (p1
.X - p2
.X)
15 let b = -(p2
.X * p1
.Y - p1
.X * p2
.Y) / (p1
.X - p2
.X)
18 let inline pointFromTwoLines
(l1
: Line) (l2
: Line) : PointF =
19 let x = -(l1
.B - l2
.B) / (l1
.A - l2
.A)
20 let y = -(l2
.A * l1
.B - l1
.A * l2
.B) / (l1
.A - l2
.A)
23 let inline linePassThroughSegment
(l
: Line) (p1
: PointF) (p2
: PointF) : bool =
24 let p = pointFromTwoLines
l (lineFromTwoPoints
p1 p2
)
25 sign
(p.X - p1.X) <> sign
(p.X - p2
.X)
27 let inline squaredDistanceTwoPoints
(p1 : PointF) (p2
: PointF) =
28 (p1.X - p2
.X) ** 2.f
+ (p1.Y - p2
.Y) ** 2.f
30 let inline distanceTwoPoints
(p1 : PointF) (p2
: PointF) =
31 squaredDistanceTwoPoints
p1 p2
|> sqrt
33 let countCells (cells
: Cell list) : int * int =
36 fun (total
, infected
) { cellClass
= cellClass
} ->
38 | HealthyRBC -> (total
+ 1, infected
)
39 | InfectedRBC -> (total
+ 1, infected
+ 1)
40 | Peculiar -> (total
, infected
)