X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FUtils.fs;h=d83bf8d0151d62da5257c10e40150976b4f3ca7c;hb=04d4504e7b248a82ddfc1a41d325e59d24146590;hp=bf245aa89ae7deb952eb506b5ebf8ad6fe91a723;hpb=4bfa3cbdc6145e6944f02e24829ab2ef3a851ac1;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaCore/Utils.fs b/Parasitemia/ParasitemiaCore/Utils.fs index bf245aa..d83bf8d 100644 --- a/Parasitemia/ParasitemiaCore/Utils.fs +++ b/Parasitemia/ParasitemiaCore/Utils.fs @@ -1,5 +1,8 @@ module ParasitemiaCore.Utils +open System +open System.Drawing + open Types let inline roundInt v = v |> round |> int @@ -7,24 +10,24 @@ let inline roundInt v = v |> round |> int let inline dprintfn fmt = Printf.ksprintf System.Diagnostics.Debug.WriteLine fmt -let inline lineFromTwoPoints (p1: PointD) (p2: PointD) : Line = +let inline lineFromTwoPoints (p1: PointF) (p2: PointF) : Line = let a = (p1.Y - p2.Y) / (p1.X - p2.X) let b = -(p2.X * p1.Y - p1.X * p2.Y) / (p1.X - p2.X) Line(a, b) -let inline pointFromTwoLines (l1: Line) (l2: Line) : PointD = +let inline pointFromTwoLines (l1: Line) (l2: Line) : PointF = let x = -(l1.B - l2.B) / (l1.A - l2.A) let y = -(l2.A * l1.B - l1.A * l2.B) / (l1.A - l2.A) - PointD(x, y) + PointF(x, y) -let inline linePassThroughSegment (l: Line) (p1: PointD) (p2: PointD) : bool = +let inline linePassThroughSegment (l: Line) (p1: PointF) (p2: PointF) : bool = let p = pointFromTwoLines l (lineFromTwoPoints p1 p2) sign (p.X - p1.X) <> sign (p.X - p2.X) -let inline squaredDistanceTwoPoints (p1: PointD) (p2: PointD) = +let inline squaredDistanceTwoPoints (p1: PointF) (p2: PointF) = (p1.X - p2.X) ** 2.f + (p1.Y - p2.Y) ** 2.f -let inline distanceTwoPoints (p1: PointD) (p2: PointD) = +let inline distanceTwoPoints (p1: PointF) (p2: PointF) = squaredDistanceTwoPoints p1 p2 |> sqrt let countCells (cells: Cell list) : int * int =