private void OnContactAdded(SolarSystemBody body) { var contact = Instantiate(ContactPrefab); contact.transform.SetParent(transform, false); contact.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = body.RadarInfo(); Contacts.Add(body, contact); }
private void OnContactRemoved(SolarSystemBody body) { if (Contacts.ContainsKey(body) == false) { return; } Destroy(Contacts[body]); Contacts.Remove(body); }
private static Exception NotSupportedExceptionBuilder(string message, SolarSystemBody solarSystemBody, CoordinateSystem coordinateSystem, ReferenceFrame referenceFrame) { var ex = new NotSupportedException(message); ex.Data.Add("SolarSystemBody", solarSystemBody); ex.Data.Add("CoordinateSystem", coordinateSystem); ex.Data.Add("ReferenceFrame", referenceFrame); return(ex); }
/// <summary> /// Computes the rectangular coordinates for a target body at a given date and with the specified reference frame. /// </summary> /// <param name="targetDate">The target date.</param> /// <param name="solarSystemBody">The solar system body.</param> /// <param name="referenceFrame">The reference frame.</param> /// <returns>RectangularCoordinates expressed in Astronomical Units (AU).</returns> public static RectangularCoordinates ComputeRectangularCoordinates(double targetDate, SolarSystemBody solarSystemBody, ReferenceFrame referenceFrame) { var file = Vsop87DataReader.SelectDataFile(solarSystemBody, CoordinateSystem.HeliocentricRectangularCoordinates, referenceFrame); var vsop87SolutionData = Vsop87DataReader.LoadVsop87DataFromFile(file); var x = ComputeVsop87Series(targetDate, vsop87SolutionData.CoordinateVariableSeriesData['X']); var y = ComputeVsop87Series(targetDate, vsop87SolutionData.CoordinateVariableSeriesData['Y']); var z = ComputeVsop87Series(targetDate, vsop87SolutionData.CoordinateVariableSeriesData['Z']); return(new RectangularCoordinates(x, y, z)); }
/// <summary> /// Computes the spherical coordinates for a target body at a given date and with the specified reference /// frame. /// </summary> /// <param name="targetDate">The target date.</param> /// <param name="solarSystemBody">The solar system body.</param> /// <param name="referenceFrame">The reference frame.</param> /// <returns>SphericalCoordinates.</returns> public static SphericalCoordinates ComputeSphericalCoordinates(double targetDate, SolarSystemBody solarSystemBody, ReferenceFrame referenceFrame) { var file = Vsop87DataReader.SelectDataFile(solarSystemBody, CoordinateSystem.HeliocentricSphericalCoordinates, referenceFrame); var vsop87SolutionData = Vsop87DataReader.LoadVsop87DataFromFile(file); var latitude = ComputeVsop87Series(targetDate, vsop87SolutionData.CoordinateVariableSeriesData['L']); var longitude = ComputeVsop87Series(targetDate, vsop87SolutionData.CoordinateVariableSeriesData['B']); var radius = ComputeVsop87Series(targetDate, vsop87SolutionData.CoordinateVariableSeriesData['R']); return(new SphericalCoordinates(latitude, longitude, radius)); }
public void Init(SolarSystemBody body, BodyTypes bodyType) { Image = GetComponent <SpriteRenderer>(); Body = body; BodyType = bodyType; switch (BodyType) { case BodyTypes.PLANET: Image.sprite = Assets.Sprites.Instance.SolarPlanet_8x8; break; case BodyTypes.STARGATE: //GetComponent<RectTransform>().sizeDelta = new Vector2(8, 8); Image.sprite = Assets.Sprites.Instance.SolarStargate_8x8; //GetComponent<RectTransform>().sizeDelta = new Vector2(Image.sprite.rect.width, Image.sprite.rect.height); Image.color = new Color(1, 1, 1, 1f); break; case BodyTypes.SUN: Image.sprite = Assets.Sprites.Instance.SolarPlanet_8x8; Image.color = Color.yellow; GenerateSolarTexture(); break; } //transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = Body.Name; }
/// <summary> /// Selects the VSOP87 data file based on the body required and the type of coordinates required. /// </summary> /// <param name="solarSystemBody">The solar system body.</param> /// <param name="coordinateSystem">The coordinate system.</param> /// <param name="referenceFrame">The reference frame.</param> /// <returns>A string containing the filename and extension (no path) of the VSOP87 data file to use.</returns> internal static string SelectDataFile(SolarSystemBody solarSystemBody, CoordinateSystem coordinateSystem, ReferenceFrame referenceFrame) { string body; string variant; const string fileNameFormat = "VSOP87{0}.{1}"; switch (solarSystemBody) { case SolarSystemBody.Sun: // when the Sun is the target body only barycentric coordinates and equinox J2000 are valid. if (coordinateSystem != CoordinateSystem.BarycentricRectangularCoordinates || referenceFrame != ReferenceFrame.EquinoxJ2000) { throw NotSupportedExceptionBuilder( "The Sun may only be used with barycentric coordinates and equinox J2000", solarSystemBody, coordinateSystem, referenceFrame); } body = "sun"; break; case SolarSystemBody.Mercury: body = "mer"; break; case SolarSystemBody.Venus: body = "ven"; break; case SolarSystemBody.Earth: // When Earth is the target body, elliptic elements are not valid. if (coordinateSystem == CoordinateSystem.HeliocentricEllipticElements) { throw NotSupportedExceptionBuilder( "Earth cannot be used with elliptic elements, please use rectangular or spherical coordinates instead.", solarSystemBody, coordinateSystem, referenceFrame); } body = "ear"; break; case SolarSystemBody.Mars: body = "mar"; break; case SolarSystemBody.Jupiter: body = "jup"; break; case SolarSystemBody.Saturn: body = "sat"; break; case SolarSystemBody.Uranus: body = "ura"; break; case SolarSystemBody.Neptune: body = "nep"; break; case SolarSystemBody.EarthMoonBarycentre: // When Earth-Moon Barycenter is the target body, only elliptical elements or rectangular J2000 coordinates are valid. if (coordinateSystem == CoordinateSystem.HeliocentricSphericalCoordinates || referenceFrame == ReferenceFrame.EquinoxJNow || coordinateSystem == CoordinateSystem.BarycentricRectangularCoordinates) { throw NotSupportedExceptionBuilder( "Earth-Moon Barycentre is only valid with equinox J2000 and either elliptic or rectangular coordinates", solarSystemBody, coordinateSystem, referenceFrame); } body = "emb"; break; default: throw NotSupportedExceptionBuilder("The specified body is not supported by VSOP87", solarSystemBody, coordinateSystem, referenceFrame); } switch (coordinateSystem) { case CoordinateSystem.HeliocentricEllipticElements: if (referenceFrame == ReferenceFrame.EquinoxJ2000) { variant = string.Empty; } else { throw NotSupportedExceptionBuilder( "Equinox of date (JNow) is not supported for elliptic elements, please use J2000, rectangular or spherical coordinates instead.", solarSystemBody, coordinateSystem, referenceFrame); } break; case CoordinateSystem.HeliocentricRectangularCoordinates: variant = referenceFrame == ReferenceFrame.EquinoxJ2000 ? "A" : "C"; break; case CoordinateSystem.HeliocentricSphericalCoordinates: variant = referenceFrame == ReferenceFrame.EquinoxJ2000 ? "B" : "D"; break; case CoordinateSystem.BarycentricRectangularCoordinates: if (referenceFrame == ReferenceFrame.EquinoxJ2000) { variant = "E"; } else { throw NotSupportedExceptionBuilder( "Equinox of date (JNow) is not supported for barycentric coordinates, please use J2000 or heliocentric coordinates instead.", solarSystemBody, coordinateSystem, referenceFrame); } break; default: throw NotSupportedExceptionBuilder("The slected coordinate system is not supported by VSOP87", solarSystemBody, coordinateSystem, referenceFrame); } var filename = string.Format(fileNameFormat, variant, body); return(filename); }
private void AddContact(SolarSystemBody body) { //if (Contacts.Contains(body) == false) Contacts.Add(body); }