Esempio n. 1
0
        PositionTest(OrbitingBodyMathematics planet,
                     DateTime test_time,
                     double expected_longitude,
                     double expected_latitude,
                     double expected_distance)
        {
            string expected_string
                = "\nExpected: longitude " + expected_longitude.ToString("F5")
                  + " degrees, latitude " + expected_latitude.ToString("F5")
                  + " degrees, distance " + expected_distance.ToString("F5")
                  + " AU";
            Vector3 coordinates = planet.current_location(test_time);
            Vector3 longlatdist = planet.current_longlatdist(test_time);

            Console.Write(coordinates.ToString("E"));
            Console.Write(longlatdist.ToString("F5"));

            double longitude_error            = Math.Abs(longlatdist.x - expected_longitude);
            double acceptable_longitude_error = 0.05;
            string longitude_error_message    = differing_results_error_message(
                Convert.ToString(longlatdist.x),
                Convert.ToString(expected_longitude),
                "degrees"
                );


            double latitude_error            = Math.Abs(longlatdist.y - expected_latitude);
            double acceptable_latitude_error = 0.01;
            string latitude_error_message    = differing_results_error_message(
                Convert.ToString(longlatdist.y),
                Convert.ToString(expected_latitude),
                "degrees"
                );


            double distance_error            = Math.Abs(longlatdist.z - expected_distance);
            double acceptable_distance_error = 0.00001;
            string distance_error_message    = differing_results_error_message(
                Convert.ToString(longlatdist.z),
                Convert.ToString(expected_distance),
                "AU"
                );

            Debug.Log(
                "Longitude Error: " + longitude_error + " degrees, "
                + "Latitude Error: " + latitude_error + " degrees, "
                + "Distance Error: " + distance_error + " AU"
                );

            Assert.LessOrEqual(longitude_error, acceptable_longitude_error,
                               "Longitude Error: " + longitude_error_message + expected_string);
            Assert.LessOrEqual(latitude_error, acceptable_latitude_error,
                               "Latitude Error: " + latitude_error_message + expected_string);
            Assert.LessOrEqual(distance_error, acceptable_distance_error,
                               "Distance Error: " + distance_error_message + expected_string);
        }