Exemplo n.º 1
0
        private void CreateSectors()
        {
            sectors = new ReferencesSector[sections, sections];

            for (int az = -180, aznr = 0; az < 180; az += 360 / sections, aznr++)
            {
                for (int alt = -90, altnr = 0; alt < 90; alt += 360 / sections, altnr++)
                {
                    ReferencesSector sector = new ReferencesSector(az, alt, 360 / sections);
                    sectors[aznr, altnr] = sector;
                }
            }
        }
        private void CreateSectors()
        {
            sectors = new ReferencesSector[sections, sections];

            for (int az = -180, aznr =0; az<180; az += 360/sections, aznr++)
            {
                for (int alt = -90, altnr =0 ; alt < 90; alt += 360 / sections, altnr++)
                {
                    ReferencesSector sector = new ReferencesSector(az, alt, 360 / sections);
                    sectors[aznr, altnr] = sector;
                 }
            }
        }
Exemplo n.º 3
0
        public ReferenceSystem GetCandidate()
        {
            double           maxdistance     = 0;
            ReferencesSector sectorcandidate = null;

            // Get Sector with maximum distance for all others...
            for (int i = 0; i < sections; i++)
            {
                for (int j = 0; j < sections / 2; j++)
                {
                    if (sectors[i, j].ReferencesCount == 0 && sectors[i, j].CandidatesCount > 0)  // An unused sector with candidates left?
                    {
                        double dist;
                        double mindist = 10;

                        for (int ii = 0; ii < sections; ii++)
                        {
                            for (int jj = 0; jj < sections / 2; jj++)
                            {
                                if (sectors[ii, jj].CandidatesCount > 0)
                                {
                                    dist = CalculateAngularDistance(sectors[i, j].AzimuthCenterRad, sectors[i, j].LatitudeCenterRad, sectors[ii, jj].AzimuthCenterRad, sectors[ii, jj].LatitudeCenterRad);

                                    if (dist > 0.001)
                                    {
                                        if (dist < mindist)
                                        {
                                            mindist = dist;
                                        }
                                    }
                                }
                            }
                        }


                        if (mindist > maxdistance)  // New candidate
                        {
                            maxdistance     = mindist;
                            sectorcandidate = sectors[i, j];
                        }
                    }
                }
            }

            if (sectorcandidate == null)
            {
                if (NrOfRefenreceSystems == 0)
                {
                    SystemClass sys = SystemClass.GetSystem("Sol");

                    if (EstimatedPosition.x == 0 && EstimatedPosition.y == 0 && EstimatedPosition.z == 0)
                    {
                        sys = SystemClass.GetSystem("Sirius");
                    }

                    if (sys == null)
                    {
                        return(null);   // Should not happend
                    }
                    ReferenceSystem refSys = new ReferenceSystem(sys, EstimatedPosition);

                    return(refSys);
                }

                return(null);
            }

            return(sectorcandidate.GetBestCandidate());
        }