1
$\begingroup$

I am creating a planetarium program using Unity3D and C# to plot out stars from the Hipparcos catalogue. Using the Plx, _RA.icrs and _DE.icrs columns of the dataset, I have managed to work the distance in parsecs and work out a cartesian set of coordinates.

Simulation Class...

public class Simulation : MonoBehaviour
{
    public IEnumerator loadStars()
    {
        starsLoaded = 0;
        var stopWatch = new Stopwatch();
        stopWatch.Start();
        // Use the last frame duration as a guide how long one frame should take
        var targetMilliseconds = Time.deltaTime * 100f;
        for (int i = 0; i < totalStars; i++)
        {
            Double.TryParse(datasetTable[i, 3], out double test);
            if (!(datasetTable[i, 12] == null) && !(datasetTable[i, 13] == null) && !(datasetTable[i, 6] == null))
            {
                GameObject thisStar = Instantiate(starPrefab, transform.position, transform.rotation) as GameObject;
                thisStar.transform.parent = starHolder.transform;
                Int32.TryParse(datasetTable[i, 0], out (thisStar.GetComponent<Star>().ID));
                Double.TryParse(datasetTable[i, 12], out (thisStar.GetComponent<Star>().RA));
                Double.TryParse(datasetTable[i, 13], out (thisStar.GetComponent<Star>().DE));
                Double.TryParse(datasetTable[i, 3], out (thisStar.GetComponent<Star>().Vmag));
                Double.TryParse(datasetTable[i, 6], out (thisStar.GetComponent<Star>().Plx));
                Double.TryParse(datasetTable[i, 10], out (thisStar.GetComponent<Star>().CI));
            }
            if (stopWatch.ElapsedMilliseconds > targetMilliseconds)
            {
                yield return null;
                stopWatch.Restart();
            }
            starsLoaded++;
        }
    }
}

Star class:

public class Star : MonoBehaviour
{
    /// <summary>
    /// Identifier (HIP number). "HIP" is appended to the ID, for Hipparcos
    /// </summary>
    [SerializeField] public int ID; // { get; set; }
    /// <summary>
    /// Right Ascension (J2000) in degrees. 
    /// </summary>
    [SerializeField] public double RA; //{ get; set; }
    /// <summary>
    /// Declination (J2000) in degrees. 
    /// </summary>
    [SerializeField] public double DE; //{ get; set; }
    /// <summary>
    /// Magnitude in Johnson V
    /// </summary>
    [SerializeField] public double Vmag; //{ get; set; }
    /// <summary>
    /// Trigonometric parallax, measured in milli-seconds of arc
    /// </summary>
    [SerializeField] public double Plx; //{ get; set; }
    /// <summary>
    /// Colour index in Johnson B-V colour
    /// </summary>
    [SerializeField] public double CI; //{ get; set; }
    /// <summary>
    /// Distance of the star from the centre of Earth measured in kilometres
    /// </summary> 
    [SerializeField] public double distanceFromEarth;
    /// <summary>
    /// Cartesian (X,Y,Z) positioning of the star
    /// </summary>
    [SerializeField] Vector3 cartesianPositioning;


    // Start is called before the first frame update
    void Start()
    {
        positionStar();
    }

    private void distanceFromEarthCalc()
    {
        // Convert Plx from milliarcseconds to arcseconds (seconds of arc)
        double PlxSOA = Plx / 1000;
        // Calculate distance from equation d=1/p
        // distance d is measured in parsecs and the parallax angle p is measured in arcseconds.
        double dPC = 1 / PlxSOA;
        /// Convert parsecs to kilomentres
        /// Conversion can bbe found here:
        /// https://en.wikipedia.org/wiki/Parsec
        /// 
        /// QUICK NOTE: converting to km causes issues with unity - values are too high
        ///             maybe work with parsecs instead?
        ///             
        //distanceFromEarth = (dPC * (96939420213600000 / math.PI_DBL)) / 1000;
        //distanceFromEarth = distanceFromEarth / 10000; // metres to kilometres
        distanceFromEarth = dPC * 10; // multiplied by 10 to move stars away from camera
    }


    private void cartesianPositioningCalc()
    {
        distanceFromEarthCalc();

        double RA_rad = RA * (math.PI_DBL / 180);
        double DE_rad = DE * (math.PI_DBL / 180);

        cartesianPositioning.x = (float)(distanceFromEarth * (math.cos(DE_rad)) * (math.cos(RA_rad)));
        cartesianPositioning.y = (float)(distanceFromEarth * (math.cos(DE_rad)) * (math.sin(RA_rad)));
        cartesianPositioning.z = (float)(distanceFromEarth * (math.sin(DE_rad)));
    }

    private void positionStar()
    {
        cartesianPositioningCalc();
        gameObject.transform.position = cartesianPositioning;
        gameObject.transform.localScale = new Vector3(2, 2, 2);
    }
}

View from the camera: View from the Unity camera

3D view of the scene (the camera's orientation is shown by the arrows): 3D view of the scene

With the image from the camera, I tried uploading it to http://nova.astrometry.net/ but was unable to find stars/constellations.

So I thought about normalising the vectors of the stars.

With the Simulation class unchanged, I changed the distanceFromEarth variable in the Star class to 900 to normalise the vectors (each star will not have the same distance from the centre)

View from the camera: View from the camera

3D view of the scene (the camera's orientation is shown by the arrows): 3D view of the scene

Even after the normalisation, uploading the image of the view from the camera to the image processing website resulted in no stars/constellations being detected.

What am I doing wrong, why aren't stars and constellation detected?

$\endgroup$
  • $\begingroup$ Try disregarding distance and set that to the same big one for each star. Scale visible size inversely to magnitude and / or limit to stars brighter than 5 mag. See weather all that combined gives you some results $\endgroup$ – planetmaker May 29 at 15:45
  • $\begingroup$ My photo.stackexchange.com/questions/92387/… discusses the size of a star on photographic medium and may or may not be helpful $\endgroup$ – user21 Jun 1 at 16:09
  • $\begingroup$ Quite helpful actually, this will come in handy when I start to create dynamic and unique models for each star $\endgroup$ – SidS Jun 1 at 18:06
2
$\begingroup$

The apparent magnitude m=Vmag could be what's missing. Stars of apparent magnitude m=0 should appear 100 times as bright as m=5 stars. If you are simulating a naked-eye view, you can omit stars of m>6.

When you place stars at nonuniform distances, you'll need to compute absolute magnitude M from apparent magnitude m and distance. If p=Plx is parallax in milliarcseconds,

$$ M \approx m + 5 \log_{10}{p} - 10 $$

If all stars are modeled in the same (emissive?) material, the object representing a star of absolute magnitude M=0 should have 100 times the surface area, and 10 times the radius, as an M=5 star.

$$ r(M) = 10^{1-M/5} r(5) $$

To check your work, planetarium sites such as TheSkyLive or Stellarium Web would be less compute-intensive than uploading images to astrometry.net.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Is there any sort of mathematical formula that can be used to calculate the radius of these star objects, given their apparent magnitude and parallax/distance from Earth (calculated from the parallax values of each star)? $\endgroup$ – SidS May 30 at 11:02
  • 1
    $\begingroup$ @SidS Updated with formulas. $\endgroup$ – Mike G May 30 at 18:24
  • 1
    $\begingroup$ I've implemented the formulas, however I don't think I've done it correctly as the stars are massive, please could you check it for me at this URL: pastebin.com/HYazJLq2 . Also, the maximum radius must be 5, how do I accomplish this. $\endgroup$ – SidS May 31 at 13:26
  • 1
    $\begingroup$ I have completely updated the script to follow suit with your answer. The script is accessible from the same URL as above. I have opened a new question regarding this at this URL: astronomy.stackexchange.com/questions/36406/… $\endgroup$ – SidS May 31 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.