X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FEEOver.fs;h=2bd13b2f6faeb744e0f0d62bfb83bf985965df11;hb=81d1b86719a1ebaf649c1de4c1364603155a53e1;hp=528632ad29fc856a6fb78d03015611dbc0e9b3a0;hpb=53440e757b4a4ab2a81b0f6a5dd1a2002c0133ba;p=master-thesis.git diff --git a/Parasitemia/Parasitemia/EEOver.fs b/Parasitemia/Parasitemia/EEOver.fs index 528632a..2bd13b2 100644 --- a/Parasitemia/Parasitemia/EEOver.fs +++ b/Parasitemia/Parasitemia/EEOver.fs @@ -69,7 +69,6 @@ let private istanpt (x: float) (y: float) (a1: float) (b1: float) (aa: float) (b then TANGENT_POINT else INTERSECTION_POINT - let private twointpts (x: float[]) (y: float[]) (a1: float) (b1: float) (phi_1: float) (a2: float) (b2: float) (h2_tr: float) (k2_tr: float) (phi_2: float) (aa: float) (bb: float) (cc: float) (dd: float) (ee: float) (ff: float) = if abs x.[0] > a1 then x.[0] <- if x.[0] < 0.0 then -a1 else a1 @@ -181,7 +180,6 @@ let private twointpts (x: float[]) (y: float[]) (a1: float) (b1: float) (phi_1: area1 + area2 - let private threeintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) (phi_1: float) (a2: float) (b2: float) (h2_tr: float) (k2_tr: float) (phi_2: float) (aa: float) (bb: float) (cc: float) (dd: float) (ee: float) (ff: float) : float = let mutable tanpts = 0 let mutable tanindex = 0 @@ -218,7 +216,7 @@ let private fourintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) ( let theta = Array.zeroCreate 4 - for i in 0..3 do + for i in 0 .. 3 do if abs xint.[i] > a1 then xint.[i] <- if xint.[i] < 0.0 then -a1 else a1 @@ -229,7 +227,7 @@ let private fourintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) ( printf "k=%d: Theta = %f, xint=%f, yint=%f\n" k theta.[k] xint.[k] yint.[k] #endif - for j in 1..3 do + for j in 1 .. 3 do let tmp0 = theta.[j] let tmp1 = xint.[j] let tmp2 = yint.[j] @@ -334,7 +332,6 @@ let private fourintpts (xint: float[]) (yint: float[]) (a1: float) (b1: float) ( area1 + area2 + area3 + area4 + area5 - let private quadroots (p: float[]) (r: float[,]) = let mutable b = -p.[1] / (2.0 * p.[0]) let c = p.[2] / p.[0] @@ -429,7 +426,6 @@ let private cubicroots (p: float[]) (r: float[,]) = for k in 1..3 do r.[2, k] <- 0.0 - let private biquadroots (p: float[]) (r: float[,]) = if p.[0] <> 1.0 then @@ -446,7 +442,7 @@ let private biquadroots (p: float[]) (r: float[,]) = a <- a - d let mutable quadExecuted = false - let quad () = + let inline quad () = if not quadExecuted then p.[2] <- c / b @@ -514,9 +510,9 @@ let private biquadroots (p: float[]) (r: float[,]) = quad () // Return a tuple (area, x intersections, y intersections) -let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float * float[] * float[]) option = - let h1, k1, a1, b1, phi_1 = e1.Cx, e1.Cy, e1.A, e1.B, e1.Alpha - let h2, k2, a2, b2, phi_2 = e2.Cx, e2.Cy, e2.A, e2.B, e2.Alpha +let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] * float32[]) option = + let h1, k1, a1, b1, phi_1 = float e1.Cx, float e1.Cy, float e1.A, float e1.B, float e1.Alpha + let h2, k2, a2, b2, phi_2 = float e2.Cx, float e2.Cy, float e2.A, float e2.B, float e2.Alpha if a1 <= EPS || b1 <= EPS || a2 <= EPS || b2 <= EPS then @@ -718,11 +714,11 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float * float[] * f | 4 -> fourintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff | _ -> -1.0 if nintpts = 0 - then Some (area, [||], [||]) + then Some (float32 area, [||], [||]) else - let xTransform = Array.zeroCreate nintpts - let yTransform = Array.zeroCreate nintpts + let xTransform : float32[] = Array.zeroCreate nintpts + let yTransform : float32[] = Array.zeroCreate nintpts for i in 0 .. (nintpts - 1) do - xTransform.[i] <- cos phi_1 * xint.[i] - sin phi_1 * yint.[i] + h1 - yTransform.[i] <- sin phi_1 * xint.[i] + cos phi_1 * yint.[i] + k1 - Some (area, xTransform, yTransform) \ No newline at end of file + xTransform.[i] <- float32 <| cos phi_1 * xint.[i] - sin phi_1 * yint.[i] + h1 + yTransform.[i] <- float32 <| sin phi_1 * xint.[i] + cos phi_1 * yint.[i] + k1 + Some (float32 area, xTransform, yTransform) \ No newline at end of file