Exemplo n.º 1
0
        public Atom(string name, Vector2 p0)
        {
            atomID = ATOM_ID++;

            Name = name;
            if (ColorMap == null)
            {
                ColorMap = new Dictionary <string, SolidBrush>();

                ColorMap.Add("Elektron", new SolidBrush(Color.Blue));
                ColorMap.Add("Proton", new SolidBrush(Color.Red));
                ColorMap.Add("Neutrone", new SolidBrush(Color.DarkGray));
            }

            Atoms = new List <Atom>();

            PositionApproximation   = new RK4(p0, DELTA0);
            PositionApproximation.f = (x, y) =>
            {
                return(VelocityApproximation.Run(y));
            };

            VelocityApproximation   = new RK4(new Vector2(), DELTA0);
            VelocityApproximation.f = (x, y) =>
            {
                Vector2 a = new Vector2();

                for (int i = 0; i < Atoms.Count; i++)
                {
                    Vector2 u = Atoms[i].PositionApproximation.Output;
                    Vector2 v = this.PositionApproximation.Output;

                    double q1 = this.q;
                    double q2 = Atoms[i].q;

                    Vector2 d = u - v;

                    double length = d.Length();
                    d /= length;



                    Vector2 F = (q1 * q2) / (4.0 * Math.PI * E0 * length * length) * d;
                    a += F / Mass;
                }

                return(a);
            };
        }
 public Vector3 v(float x, Vector3 position)
 {
     return(VelocityApproximation.Run(position));
 }