/// <summary> /// Returns the gravitional force between A & B, in the direction of A to B /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> private static Vector2f ForceBetweenPlanets(Planet a, Planet b) { var d = Utils.Distance(a.Position, b.Position); var forceMag = m_GravConst * (a.Mass * b.Mass) / d; //Newton's Law of Universal Gravitation var forceVector = b.Position - a.Position; forceVector /= (float)d; //reduce to unit vector forceVector *= (float)forceMag; //scale to proper magnitude return forceVector; }
private bool PositionFree(Point target) => Planet.IsInBounds(target) && Planet.Population.All(p => p.Position != target) && Planet.Bushes.All(b => b.Position != target);
static public Vector2 GetDistanceVector(Planet planet1, Planet planet2) { return(planet2.Position - planet1.Position); }