Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            PointMass[] pointMasses = new PointMass[] {
                new PointMass(3, new Vector(2, 3)),
                new PointMass(1, new Vector(6, 3))
            };

            double[] radii = new double[] { 0.6, 0.2 };

            for (int i = 0; i < pointMasses.Length; i++)
            {
                this.AddCircle(pointMasses[i], radii[i] * 100);
            }

            double ds = 0.1;

            this.Chart.AddLinePlot(Assignment8.EquipotentialLine(pointMasses, new Vector(6.9, 3), ds).Select(v => new Point(v.X, v.Y)));

            for (int i = 1; i <= 6; i++)
            {
                double angle    = 0.5 + i;
                Vector position = pointMasses[1].Position + new Vector(Math.Cos(angle), Math.Sin(angle)) * radii[1];
                this.Chart.AddLinePlot(
                    Assignment8.FieldLine(pointMasses, position, ds, this.Chart.XMin, this.Chart.XMax, this.Chart.YMin, this.Chart.YMax)
                    .Select(v => new Point(v.X, v.Y)));
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        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;
                }
            }
        }