private double AbsTan(DoublePoint input) { return(Math.Atan(Math.Abs(input.Y) / Math.Abs(input.X))); }
public Source(DoublePoint initPos, long initMass, Timer stepTimer, int MASSHANDLER, long DISTANCESCALERIn) { Pos = initPos; Mass = initMass; G = 6.7 * Math.Pow(10, -11 + MASSHANDLER) * stepTimer.Interval / 1000; DISTANCESCALER = DISTANCESCALERIn; }
private DoublePoint GetDistanceFrom(DoublePoint target) { //diff b/ween points return(new DoublePoint(target.X - Pos.X, target.Y - Pos.Y)); }
private void TIM_main_Tick(object sender, EventArgs e) { //totalstrength is resultant accel, indiv is accel due to individual sources DoublePoint totalStrength, indivStrength; Obj obj; bool delete = false; for (int i = 0; i <= objs.Count - 1; i++) { obj = objs[i]; //steps accel and v obj.Step(); totalStrength = new DoublePoint(0, 0); //for every source, find accel on this obj, and add to resultant foreach (Source s in sources) { indivStrength = s.GetStrengthAtPoint(obj.Pos); if (!(indivStrength == null)) { totalStrength.X += indivStrength.X; totalStrength.Y += indivStrength.Y; } else { delete = true; } } if (TS_objGrav.Checked) { for (int a = 0; a <= objs.Count - 1; a++) { if (!(a == i)) { indivStrength = objs[a].GetStrengthAtPoint(obj.Pos); if (!(indivStrength == null)) { totalStrength.X += indivStrength.X; totalStrength.Y += indivStrength.Y; } else { delete = true; } } } if (delete) { objs.Remove(objs[i]); if (TS_trail.Checked) { p1.Remove(p1[i]); } } } //change accel by resultant obj.ApplyAccel(totalStrength); } for (int i = 0; i <= objs.Count - 1; i++) { if (objs[i].Pos.X > MAXINT || objs[i].Pos.X <-MAXINT || objs[i].Pos.Y> MAXINT || objs[i].Pos.X < -MAXINT) { objs.Remove(objs[i]); if (TS_trail.Checked) { p1.Remove(p1[i]); } } } //focus section foreach (Obj o in objs) { if (o.Container.Contains(PB_main.PointToClient(MousePosition))) { o.Focused = true; foreach (Obj a in objs) { if (!(o == a)) { a.Focused = false; } } } } foreach (Obj o in objs) { if (o.Focused) { RTXT_focused.Text = o.GetReadout(); } } PB_main.Refresh(); }