public static IEnumerable <Vector> FieldLine(PointMass[] pointMasses, Vector start, double ds, double xMin, double xMax, double yMin, double yMax) { Vector position = new Vector(start.X, start.Y); Vector g = Assignment8.g(pointMasses, start); Vector step = new Vector(-g.X, -g.Y) * ds / g.Length; while (position.X > xMin && position.X < xMax && position.Y > yMin && position.Y < yMax) { yield return(position); position = position + step; g = Assignment8.g(pointMasses, position + step / 2); step = new Vector(-g.X, -g.Y) * ds / g.Length; } }
public static IEnumerable <Vector> EquipotentialLine(PointMass[] pointMasses, Vector start, double ds) { Vector position = new Vector(start.X, start.Y); bool test = false; Vector g = Assignment8.g(pointMasses, start); Vector step = new Vector(g.Y, -g.X) * ds / g.Length; while (position.Y < start.Y + ds || !test) { yield return(position); position = position + step; g = Assignment8.g(pointMasses, position + step / 2); step = new Vector(g.Y, -g.X) * ds / g.Length; if (position.Y < start.Y) { test = true; } } }