/// <summary>
 /// Constructor, given an ordinal coordinate for the system
 /// </summary>
 /// <param name="p"></param>
 public StellarSystem(PlotPoint p)
 {
     this.location = new PlotPoint(p);
     this.ourPlanets = new List<Planet>();
     this.stellarMembers = new List<AstronomicalObject>();
     this.systemHistory = new StellarHistoryLogger();
 }
        /// <summary>
        /// This function creates the sector, and initiates it.
        /// </summary>
        /// <param name="s">Our sector</param>
        internal void initateSector(Sector s)
        {
            //first set the sector name
            s.setSectName(prgSettings.getSectorPrefix() + this.velvetBag.rng(1, prgSettings.getSectorMaxNum()));

            //get values
            double minStellarDistance = this.prgSettings.getMinStellarDistance() * this.prgSettings.getLightYearResolution();
            double stellarDensity = this.prgSettings.getStellarDensity();
            bool isTwoDGrid = !(this.prgSettings.gridTypeIs3D());
            int gridLimit = this.prgSettings.getLightYearResolution() * this.prgSettings.getSectorSizePerSide();

            //do any alterations now.
            if (isTwoDGrid)
                stellarDensity = stellarDensity * this.prgSettings.getTwoDMultiplication();

            //list of points time
            List<PlotPoint> ourPoints = new List<PlotPoint>();

            //Fixed an intersting bug. Always one under. Now using Ceiling...
            int numberOfStars = (int)Math.Ceiling(Math.Pow(this.prgSettings.getSectorSizePerSide(), 3) * stellarDensity);

            for (int i = 0; i < numberOfStars; i++)
            {
                PlotPoint newPoint = new PlotPoint(0, 0, 0); //generic point.

                do
                {
                    newPoint.SetCoords(new int[] {velvetBag.rng(1, gridLimit), velvetBag.rng(1, gridLimit), velvetBag.rng(1, gridLimit) });
                } while (((from c in ourPoints where c.GetDistance(newPoint) <= minStellarDistance select c).Any()));

                ourPoints.Add(new PlotPoint(newPoint));
            }

            //our points are now generated. Let's add them to the sector.
            for (int i = 0; i < ourPoints.Count; i++)
            {
                s.ourSystem.Add(new StellarSystem(ourPoints[i]));
            }

            //We're done setting sector
            this.systemsInitiated = true;
        }
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="c">PlotPoint being copied</param>
 public PlotPoint(PlotPoint c)
 {
     this.ptX = c.GetCoordX();
     this.ptY = c.GetCoordY();
     this.ptZ = c.GetCoordZ();
 }
        /// <summary>
        /// Calculates the distance from this point and the new point
        /// </summary>
        /// <param name="B">The plot point being compared from</param>
        /// <returns>The distance</returns>
        public double GetDistance(PlotPoint B)
        {
            double distX, distY, distZ;

            distX = Math.Pow(B.GetCoordX() - this.ptX, 2);
            distY = Math.Pow(B.GetCoordY() - this.ptY, 2);
            distZ = Math.Pow(B.GetCoordZ() - this.ptZ, 2);

            return Math.Sqrt(distX + distY + distZ);
        }