X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FEEOver.fs;h=52b59636eeadbe631cc74dcb44b706254e56deab;hp=489105940e91a575522666029c2c4dc7abf57d36;hb=e76da913cd58078ad2479357b2430ed62a6e0777;hpb=dec96d50e56e1932bbfa09e6bedf90d6b707ccbd diff --git a/Parasitemia/Parasitemia/EEOver.fs b/Parasitemia/Parasitemia/EEOver.fs index 4891059..52b5963 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,32 @@ 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 + if nintpts = 0 + then Some (area, [||], [||]) + else + let xTransform = Array.zeroCreate nintpts + let yTransform = 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