//public Molecule(Painter p, DataAtom a) //{ // center = new Point(0, 0); // if (a.Mol > 1) // { // angle = 360 / a.Mol - 1; // } // radius = a.Shells * 17 + 10; // atoms = new List<Atom>(); // for (int i = 0; i < a.Mol; i++) // { // Point c = new Point(2 * radius * Math.Cos(angle * Math.PI / 180) + Center.X, 2 * radius * Math.Sin(angle * Math.PI / 180) + Center.Y); // atoms.Add(new Atom(a,c,p,(i==0 ? 0:1))); // } // parent = p; //} public Molecule(Painter p, DataAtom a, Point cent, int number) { radius = a.Shells * 14 + 5; atoms = new List <Atom>(); int fact = 0;; center = cent; if (a.Mol > 1) { angle = 360 / a.Mol - 1; } for (int i = 0; i < a.Mol; i++) { fact = (a.Mol == 1 ? 0 : radius); Point c = new Point(fact * Math.Cos(i * angle * Math.PI / 180) + Center.X, fact * Math.Sin(i * angle * Math.PI / 180) + Center.Y); atoms.Add(new Atom(a, c, p, (i == 0?0:1), number)); } parent = p; }
public Atom(DataAtom a, Point c, Painter p, double direction, int number) { molName = number; this.direction = direction; parent = p; picsPerSec = 24; center = c; this.name = a.Name; int weight = a.Weight - a.OuterWeight; shells = new List <Shell>(); int counter = 1; int data; while (weight > 0) { data = (int)(2 * Math.Pow(counter, 2)); shells.Add(new Shell(counter, (weight > data ? data : weight), Center)); weight -= data; counter++; } shells.Add(new Shell(a.Shells, a.OuterWeight, center)); myRadius = 17 * shells.Count() + 10; }
public void Add(DataAtom a) { Childrens.Add(new Molecule(this, a, clicked, Childrens.Count)); }