X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FEEOver.fs;fp=Parasitemia%2FParasitemia%2FEEOver.fs;h=81bdbf808fb08b746af7a7681c68b91503876ceb;hb=06bd63d8c01100c28873dfafd59b5efccbfb67e4;hp=489105940e91a575522666029c2c4dc7abf57d36;hpb=dec96d50e56e1932bbfa09e6bedf90d6b707ccbd;p=master-thesis.git diff --git a/Parasitemia/Parasitemia/EEOver.fs b/Parasitemia/Parasitemia/EEOver.fs index 4891059..81bdbf8 100644 --- a/Parasitemia/Parasitemia/EEOver.fs +++ b/Parasitemia/Parasitemia/EEOver.fs @@ -512,14 +512,14 @@ let private biquadroots (p: float[]) (r: float[,]) = quad () - -let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : float = +// 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 if a1 <= EPS || b1 <= EPS || a2 <= EPS || b2 <= EPS then - -1.0 + None else let phi_1 = phi_1 % Math.PI let phi_2 = phi_2 % Math.PI @@ -696,22 +696,24 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : float = if returnValue = -1.0 then - returnValue + None else - match nintpts with - | 0 | 1 -> nointpts a1 b1 a2 b2 h1 k1 h2 k2 phi_1 phi_2 h2_tr k2_tr aa bb cc dd ee ff - | 2 -> match istanpt xint.[0] yint.[0] a1 b1 aa bb cc dd ee ff with - | TANGENT_POINT -> + let area = + match nintpts with + | 0 | 1 -> nointpts a1 b1 a2 b2 h1 k1 h2 k2 phi_1 phi_2 h2_tr k2_tr aa bb cc dd ee ff + | 2 -> match istanpt xint.[0] yint.[0] a1 b1 aa bb cc dd ee ff with + | TANGENT_POINT -> #if DEBUG_LOG - printf "one point is tangent\n" + printf "one point is tangent\n" #endif - nointpts a1 b1 a2 b2 h1 k1 h2 k2 phi_1 phi_2 h2_tr k2_tr aa bb cc dd ee ff + nointpts a1 b1 a2 b2 h1 k1 h2 k2 phi_1 phi_2 h2_tr k2_tr aa bb cc dd ee ff - | INTERSECTION_POINT -> + | INTERSECTION_POINT -> #if DEBUG_LOG - printf "check twointpts\n" + printf "check twointpts\n" #endif - twointpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff - | 3 -> threeintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff - | 4 -> fourintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff - | _ -> -1.0 + twointpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff + | 3 -> threeintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff + | 4 -> fourintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff + | _ -> -1.0 + Some (area, xint.[..nintpts-1], yint.[..nintpts-1]) \ No newline at end of file