using System; namespace Science.Mathematics.VectorCalculus { public class SurfaceIntegral { private Surface s; private double res; private VectorField F; public SurfaceIntegral(Function.ToLastType function, Surface surface) { VectorField vf = new VectorField(function); F = vf; s = surface; } public SurfaceIntegral(VectorField vectorField, Surface surface) { F = vectorField; s = surface; } public void Compute() { double[] f = { s.Parameter1StartValue, s.Parameter2StartValue }; double[] t = { s.Parameter1EndValue, s.Parameter2EndValue }; Function.ToLastType fdots = new Function.ToLastType(Func); IntegrationMultiD obj = new IntegrationMultiD(fdots, f, t); obj.NumberOfCall = nc; obj.Compute(); res = obj.BestEstimation; tgral = obj.BestEstimation; sd = obj.StandardDeviation; chi2 = obj.ChiSQUARE; } private double Func(double[] u) { TangentVectorOnSurface tv = new TangentVectorOnSurface(s, u); tv.Compute(); Vector n = tv.Result[0] % tv.Result[1]; double[] x = s.Parametrization(u); Point at = new Point(x); F.FindComponents(at); return n*F; } public double Result { get { return res; } } private double tgral, sd, chi2; private ulong nc = 100000; public double BestEstimation { get { return tgral; } } public double StandardDeviation { get { return sd; } } public double ChiSQUARE { get { return chi2; } } public ulong NumberOfCall { set { nc = value; } } } }