Ejemplo n.º 1
0
        public void TestFilepath()
        {
            StarMapReader smr  = new StarMapReader();
            List <Star>   list = smr.fileToList(path);

            Assert.IsTrue(list.Count == 17, "17 total stars in list read from path");
        }
Ejemplo n.º 2
0
        public void TestEmptyLinesInInputFiles()
        {
            StarMapReader smr  = new StarMapReader();
            List <Star>   list = smr.stringToList(text);

            Assert.IsTrue(list.Count == 6, "must be 6 stars total with empty line");
        }
Ejemplo n.º 3
0
        public void TestPartialOrMisformattedLines()
        {
            StarMapReader smr   = new StarMapReader();
            List <Star>   list3 = smr.stringToList(text3);

            Assert.IsTrue(list3.Count == 5, "must be 5 after partial line and misformatted line");
        }
Ejemplo n.º 4
0
    public static void Main()
    {
        //Console.WriteLine(obj.readFile());

        /*
         * string liney = "0.933979 0.179802 -0.308796 4128 2.04 188 DIPHDA; DENEB KAITOS";
         * string[] wordies = liney.Split(' ');
         * List<string> listy = Words.getWords(wordies);
         * string[] finalprops = Words.getProperties(wordies);
         *
         * foreach(string name in listy)
         * {
         *      Console.WriteLine(name);
         * }
         */

        string path = @"/Users/eliaanagnostou/Documents/cs71/01-constellations/StarMap/Maps/Hydra.txt";
        string text = @"0.994772 0.023164 -0.099456 28 4.61 3
0.972490 0.024187 0.231685 87 5.55 4
0.435119 0.012234 0.900290 144 5.57 7
0.998442 0.033711 -0.044468 315 6.43 11
0.998448 0.035746 -0.042707 352 6.18 14
0.873265 0.031968 0.486196 358 2.07 15 ALPHERATZ
0.512379 0.020508 0.858515 432 2.28 21 CAPH; CAS BETA
0.949168 0.037455 0.312534 448 5.57 22
0.882312 0.036017 -0.469285 493 5.42 24
0.697240 0.028641 -0.716265 496 3.88 25
0.980198 0.042952 0.193306 560 5.54 26
0.693047 0.031231 0.720216 571 5.01 27
0.135171 0.005924 -0.990805 636 5.29 30
0.962619 0.047354 -0.266689 693 4.89 33
0.883455 0.044652 -0.466383 720 5.41 34
0.816743 0.041844 -0.575482 739 5.24 35
0.963482 0.055705 0.261913 886 2.83 39 ALGENIB";
        List <StarMapReader> starList = StarGroup.stringToList(text);
        List <StarMapReader> list     = Star.GetList();

        foreach (StarMapReader star in list)
        {
            Console.WriteLine(star.getX);
        }

        StarMapReader.RemoveAllStars();

        foreach (StarMapReader star in list)
        {
            Console.WriteLine(star.getX);
        }

        //foreach(StarMapReader star in starList)
        //{
        //	Console.Write(star.getNames().Any());
        //}
        //Console.WriteLine(StarMapReader.getCoordsByName("ALPHERATZ", starList).getX());

        //Console.WriteLine(StarMapReader.getStarAmount(starList));

        //Constellation con = Constellation.fileToList(path);
        //Console.WriteLine(con.getEndpointAt(3));
    }
Ejemplo n.º 5
0
        public void TestAnyNumberOfNames()
        {
            StarMapReader smr   = new StarMapReader();
            List <Star>   list2 = smr.stringToList(text2);

            Console.WriteLine(list2[0].getNames().Count);
            Assert.IsTrue(list2[0].getNames().Count == 0, "names of first star of list are 0");
            Assert.IsTrue(list2[1].getNames().Count == 5, "names of second star of list are 5");
        }
Ejemplo n.º 6
0
        public void TestChangedDataWithinReader()
        {
            StarMapReader smr   = new StarMapReader();
            List <Star>   list  = smr.stringToList(text);
            List <Star>   list2 = smr.stringToList(text2);

            Assert.IsTrue(list2.Count == 11, "11 stars total after update");
            Assert.IsTrue(list2[7].getNames().Count == 5, "names of star are 5");
        }
Ejemplo n.º 7
0
    /* ARGS: none
     *  RETURN: the coordinates of every member of the constellation
     */
    public List <StarCoords> CoordsInConstellation()
    {
        List <StarCoords> coords = new List <StarCoords>();
        StarMapReader     smr    = new StarMapReader();
        List <Star>       list   = smr.fileToList(@"../../../../StarMap/Maps/stars.txt");

        foreach (Endpoint point in _lines)
        {
            coords.Add(Star.getCoordsByName(point.getStart(), list));
        }

        return(coords);
    }
Ejemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        string        text     = textFile.text;
        StarMapReader smr      = new StarMapReader();
        List <Star>   starList = smr.stringToList(text);

        foreach (Star star in starList)
        {
            GameObject newObj = GameObject.Instantiate(template);

            float x = star.getX();
            float y = star.getY();
            float z = star.getZ();
            //float z = Random.Range(-10, 10);
            newObj.transform.position    = new Vector3(x, y, z);
            newObj.transform.localScale += new Vector3(star.getMag() * 0.005f, star.getMag() * 0.005f, star.getMag() * 0.005f);
        }

        foreach (TextAsset constellation in constellations)
        {
            string        textCon = constellation.text;
            Constellation constel = Constellation.stringToList(textCon);

            for (int i = 0; i < constel.getNumberOfLines(); i++)
            {
                Vector3 pos1 = new Vector3(Star.getCoordsByName(constel.getEndpointAt(i).getStart(), starList).getX(), Star.getCoordsByName(constel.getEndpointAt(i).getStart(), starList).getY(), Star.getCoordsByName(constel.getEndpointAt(i).getStart(), starList).getZ());
                Vector3 pos2 = new Vector3(Star.getCoordsByName(constel.getEndpointAt(i).getEnd(), starList).getX(), Star.getCoordsByName(constel.getEndpointAt(i).getEnd(), starList).getY(), Star.getCoordsByName(constel.getEndpointAt(i).getEnd(), starList).getZ());
                Vector3 dir  = pos2 - pos1;

                GameObject cylinderObj = GameObject.Instantiate(cylTemplate);
                cylinderObj.transform.position = 0.5f * (pos1 + pos2);
                cylinderObj.transform.rotation = Quaternion.LookRotation(dir) * Quaternion.Euler(90, 0, 0);

                Vector3 scale = cylinderObj.transform.localScale;
                scale.y = 0.5f * dir.magnitude;
                cylinderObj.transform.localScale = scale;
            }
        }
    }