// Main Constructor using Vector paramaters public InterstellaObjectParams ( Vector position, Vector velocity, Vector acceleration, InterstellaObjectType type, double mass = double.NaN, double radius = double.NaN ) { // If mass or density are not supplied get their default values from Defaults if (double.IsNaN(mass)) { mass = (double)InterstellaObjectTypeDefaults.getDefaults(type)["mass"]; } if (double.IsNaN(radius)) { radius = (double)InterstellaObjectTypeDefaults.getDefaults(type)["radius"]; } Position = position; Velocity = velocity; Acceleration = acceleration; Mass = mass; Radius = radius; Type = type; }
/// <summary> /// A Constuctor for creating a copy of an existing instance of an InterstellaObject /// /// Base Moving object given the paramaters for it's constructor /// </summary> public InterstellaObject(InterstellaObject copyObject) : base(copyObject.Position, copyObject.Velocity, copyObject.Acceleration) { _ResultantForce = new Vector(0, 0); _Type = copyObject.Type; _Mass = copyObject.Mass; _Radius = copyObject.Radius; }
/// <summary> /// Constructor to create a new intance of an interstella Object from a InterstellaObject Paramater object /// </summary> /// <param name="paramaters"><see cref="InterstellaObjectParams"/></param> public InterstellaObject(InterstellaObjectParams paramaters) : base(paramaters.Position, paramaters.Velocity, paramaters.Acceleration) { // Params for MovingObject constructor given to base. // Resultant force starts at 0 _ResultantForce = new Vector(0, 0); // Fields set from paramaters _Type = paramaters.Type; _Mass = paramaters.Mass; _Radius = paramaters.Radius; }
// Chained Constructor to convert Vector components into Vectors for main constructor public InterstellaObjectParams ( double xPosition, double yPosition, double xVelocity, double yVelocity, double xAcceleration, double yAcceleration, InterstellaObjectType type, double mass = double.NaN, double radius = double.NaN ) : this ( new Vector(xPosition, yPosition), new Vector(xVelocity, yVelocity), new Vector(xAcceleration, yAcceleration), type, mass, radius ) { }
/// <summary> /// Gets the set defaults for an interstellarObjectType /// </summary> /// <param name="type"></param> /// <returns>a dictionary of the defaults keys and values</returns> public static Dictionary <string, object> getDefaults(InterstellaObjectType type) { switch (type) { case InterstellaObjectType.Star: Dictionary <string, object> StarDefaults = new Dictionary <string, object>(); StarDefaults.Add("mass", SolarSystemConstants.SunMass); StarDefaults.Add("radius", 6.96E8); return(StarDefaults); case InterstellaObjectType.RockyPlanet: Dictionary <string, object> RockyPlannetDefaults = new Dictionary <string, object>(); RockyPlannetDefaults.Add("mass", 4.9E24); RockyPlannetDefaults.Add("radius", 6.052E6); return(RockyPlannetDefaults); case InterstellaObjectType.Moon: Dictionary <string, object> MoonDefaults = new Dictionary <string, object>(); MoonDefaults.Add("mass", SolarSystemConstants.MoonMass); MoonDefaults.Add("radius", 1.737E6); return(MoonDefaults); case InterstellaObjectType.EarthSizedPlannet: Dictionary <string, object> EarthDefaults = new Dictionary <string, object>(); EarthDefaults.Add("mass", SolarSystemConstants.EarthMass); EarthDefaults.Add("radius", 6.37E6); return(EarthDefaults); case InterstellaObjectType.GasGiant: Dictionary <string, object> GasGiantDefaults = new Dictionary <string, object>(); GasGiantDefaults.Add("mass", 1.8982E27); GasGiantDefaults.Add("radius", 69911E3); return(GasGiantDefaults); case InterstellaObjectType.IceGiant: Dictionary <string, object> IceGiantDefaults = new Dictionary <string, object>(); IceGiantDefaults.Add("mass", 8.6810E25); IceGiantDefaults.Add("radius", 2.5362E7); return(IceGiantDefaults); case InterstellaObjectType.Asteroid: Dictionary <string, object> AsteroidDefaults = new Dictionary <string, object>(); AsteroidDefaults.Add("mass", 9.393E20); AsteroidDefaults.Add("radius", 4.73E5); return(AsteroidDefaults); case InterstellaObjectType.DwarfPlanet: Dictionary <string, object> DwarfPlanetDefaults = new Dictionary <string, object>(); DwarfPlanetDefaults.Add("mass", 1.303E22); DwarfPlanetDefaults.Add("radius", 1.1883E6); return(DwarfPlanetDefaults); default: throw new InvalidOperationException(); } }