using System; namespace Science.Mathematics.VectorCalculus { public class VectorField : Vector { private Function.ToLastType f; public VectorField(Function.ToLastType function) : base() { f = function; } public void FindComponents(Point at) { el = f(at.Coordinate); } public bool ConservativeQ(Point at0, Point at1, Point at2) { Curl obj = new Curl(f,at0.Coordinate); obj.Compute(); if(obj.Result.Norm > 0.0000001) return false; obj.At = at1.Coordinate; obj.Compute(); if (obj.Result.Norm > 0.0000001) return false; obj.At = at2.Coordinate; obj.Compute(); if (obj.Result.Norm > 0.0000001) return false; return true; } private Point xx; public double Potential(Point x) { xx = x; Function.ToLastType pp = new Function.ToLastType(path); Path pa = new Path(pp); pa.ParameterFrom = 0.0; pa.ParameterTo = 3.0; LineIntegral obj = new LineIntegral(this, pa); obj.Compute(); return obj.Result; } private double[] path(double t) { double[] p = new double[3]; if (t < 1.0) { p[0] = t * xx.Coordinate[0]; p[1] = 0.0; p[2] = 0.0; } else if (t > 1.0 & t < 2.0) { p[0] = xx.Coordinate[0]; p[1] = (t - 1.0)*xx.Coordinate[1]; p[2] = 0.0; } else { p[0] = xx.Coordinate[0]; p[1] = xx.Coordinate[1]; p[2] = (t - 2.0)*xx.Coordinate[2]; } return p; } } }