Ejemplo n.º 1
0
	public PlanetModel FindPlanet(EquatorialCoords eq){
		PlanetModel planet = null;
		if( planetPositionsDictionary.TryGetValue(eq, out planet) ){
			return planet;
		}
		return null;
	}
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        try{
            Vector3 mousePos = Input.mousePosition;
            mousePos.z = SimController.INSTANCE.radius;

            Vector3 pointingAt = Camera.main.ScreenToWorldPoint(mousePos);


            LocalCoords local = SkyModel.Rectangular2Horizontal((double)pointingAt.x, (double)pointingAt.y, (double)pointingAt.z);

            EquatorialCoords equatorial = skyModel.Horizontal2Equatorial(
                local.Azimuth.Get(),
                local.Altitude.Get()
                );


            DisplaySelectedBodyDetailsIfAny(equatorial);


            raDecGUI.text = string.Format("RA/Dec: {0} / {1}", equatorial.RA.ToString(), equatorial.Declination.ToString());

            azimuthAltGUI.text = string.Format("Az/Alt: {0} / {1}", local.Azimuth.To0To360Range().ToString(), local.Altitude.ToString());

            fovGUI.text = "FOV: " + Camera.main.fieldOfView + "º";

            raDecGUI.color = azimuthAltGUI.color = fovGUI.color = sim.Settings.MouseHudColor;
        }catch (NullReferenceException n) {
            Debug.Log(n);
        }
    }
Ejemplo n.º 3
0
	public CelestialBody FindCelestialBody(EquatorialCoords eq){
		int index = 0;

		//is it a star?
		if (starPositionsDictionary.TryGetValue(eq, out index)){			
			return stars [ index ] as StarModel;	
		}

		//is it a planet?
		PlanetModel planet = null;
		foreach(KeyValuePair<string, PlanetModel> current in planets){
			if(current.Value.EquatorialCoords.EqualsThreshold(eq, 5)){
				planet = current.Value;
				break;
			}
		}		
		if(planet != null){ 
			return planet as PlanetModel;
		}


		//is it the moon?
		if(moon.EquatorialCoords.Equals(eq)){
			return moon as MoonModel;
		}

		//is it the sun?
		if (sun.EquatorialCoords.Equals (eq)) {
			return sun as SunModel;
		}

		return null;
	}
Ejemplo n.º 4
0
	public StarModel FindStar(EquatorialCoords eq){

		int index = 0;

		if (starPositionsDictionary.TryGetValue(eq, out index)){			
			return stars [ index ];	
		}

		return null;
	}
Ejemplo n.º 5
0
	public void PopulateStarPositionsDictionary(){
		foreach (StarModel star in stars) {
			DegreesAngle dec = new DegreesAngle (star.dec);
			HourAngle ra = new HourAngle (star.ra);

			EquatorialCoords eq = new EquatorialCoords (ra, dec);

			starPositionsDictionary [eq] = star.starID - 1;

		}			
	}
Ejemplo n.º 6
0
        public Astrobody(AstrobodyConstants constants)
        {
            this.constants       = constants;
            this.orbitalElements = new OrbitalElements();

            this.eclipticCartLocal = new CartesianCoords();
            this.eclipticCartHelio = new CartesianCoords();
            this.eclipticCartGeo   = new CartesianCoords();

            this.equatorialCartGeo = new CartesianCoords();

            this.ecliptic   = new EclipticCoords();
            this.equatorial = new EquatorialCoords();
        }
Ejemplo n.º 7
0
    private void DisplayCrossHair()
    {
        crosshair.SetActive(true);
        EquatorialCoords eq          = GetSelectedBodyEqCoords();
        Vec3D            rectangular = eq.ToRectangular();

        crosshair.transform.localPosition = new Vector3((float)rectangular.x, (float)rectangular.y, -(float)rectangular.z) * sim.radius;


        float fov = Camera.main.fieldOfView;

        crosshairRenderer.scale        = 0.03f * fov * fov + 5f;
        crosshairRenderer.radius       = crosshairRadius;
        crosshairRenderer.sizeOnScreen = crosshairSize;
    }
Ejemplo n.º 8
0
    void DisplaySelectedBodyDetailsIfAny(EquatorialCoords equatorial)
    {
        if (Input.GetMouseButtonUp(0))
        {
            //is it a solar system body?
            if (CheckSolarSystemBodyHit())
            {
                DisplayBodyDetailsByType();
                DisplayCrossHair();
            }
            else
            {
                //is it a star?
                selectedBody = skyModel.FindStar(equatorial);
                if (selectedBody != null)
                {
                    StarModel star = (StarModel)selectedBody;
                    crosshairRadius = 5f;
                    crosshairSize   = 50 / (3 + star.mag);

                    DisplayBodyDetailsByType();
                    DisplayCrossHair();
                }
                else
                {
                    crosshair.SetActive(false);
                    detailsGUI.text = "";
                }
            }
        }

        if (selectedBody != null)
        {
            DisplayBodyDetailsByType();
            DisplayCrossHair();
        }
    }
Ejemplo n.º 9
0
    public StarModel(string[] data)
    {
        try{
            int len = data.Length;
            int.TryParse(data [Star.StarID], out starID);
            int.TryParse(data [Star.HIP], out hip);
            double.TryParse(data [Star.RA], out ra);
            double.TryParse(data [Star.Dec], out dec);
            float.TryParse(data [Star.Mag], out mag);
            float.TryParse(data [Star.ColorIndex], out colorIndex);
            float.TryParse(data [Star.AbsMag], out absMag);
            double.TryParse(data[Star.Distance], out distance);
            bayerFlamsteed = data[Star.BayerFlamsteed];
            properName     = data[Star.ProperName];
            gliese         = data[Star.Gliese];
            float.TryParse(data[Star.ColorIndex], out colorIndex);

            spectrum = data[Star.Spectrum];

            equatorialCoords = new EquatorialCoords(new HourAngle(ra), new DegreesAngle(dec));
        }catch (FormatException pe) {
            Debug.Log(string.Format("EXCEPTION: {0}", pe.ToString()));
        }
    }