Exemple #1
0
        public void Can_rotate_around_z(double initialX, double initialY, double initialZ, double rotationAngleDegrees, double expectedX, double expectedY, double expectedZ)
        {
            var point = new Cartesian3D(initialX, initialY, initialZ);

            var result = point.RotateZ(Angle.From(Degrees.FromRaw(rotationAngleDegrees)));

            Assert.Equal(new Cartesian3D(expectedX, expectedY, expectedZ), result);
        }
Exemple #2
0
        public void Can_create(double rawLat, double rawLon)
        {
            var lat   = Angle.From(Degrees.FromRaw(rawLat));
            var lon   = Angle.From(Degrees.FromRaw(rawLon));
            var point = new Geodesic(lat, lon);

            Assert.Equal(lat, point.Latitude);
            Assert.Equal(lon, point.Longitude);
        }
Exemple #3
0
        public void Can_rotate_about_origin(double initialX, double initialY, double rotationAngleDegrees, double expectedX, double expectedY)
        {
            var point         = new Cartesian2D(initialX, initialY);
            var rotationAngle = Angle.From(Degrees.FromRaw(rotationAngleDegrees));

            var result = point.Rotate(Angle.From(Degrees.FromRaw(rotationAngleDegrees)));

            Assert.Equal(new Cartesian2D(expectedX, expectedY), result);
        }
        public void Can_calculate_arctan_of_angle()
        {
            var value    = 0.5773502691996256;
            var expected = Angle.From(Degrees.FromRaw(30));

            var result = Atan(value);

            Assert.Equal(expected.Degrees.Value, result.Degrees.Value, 5);
        }
Exemple #5
0
        public void Can_create(double rawPhi, double rawTheta, double r)
        {
            var phi   = Angle.From(Degrees.FromRaw(rawPhi));
            var theta = Angle.From(Degrees.FromRaw(rawTheta));
            var point = new Spherical(phi, theta, r);

            Assert.Equal(phi, point.Phi);
            Assert.Equal(theta, point.Theta);
            Assert.Equal(r, point.R);
        }
        public void Can_calculate_tan_of_angle()
        {
            var angle = Angle.From(Degrees.FromRaw(30));

            var result = Tan(angle);

            var expected = 0.5773502691996256;

            Assert.Equal(expected, result, DoubleComparisonPrecision);
        }
        public void Can_calculate_cos_of_angle()
        {
            var angle = Angle.From(Degrees.FromRaw(90));

            var result = Cos(angle);

            var expected = 0;

            Assert.Equal(expected, result, DoubleComparisonPrecision);
        }
Exemple #8
0
        public void Longitude_outside_range_0_to_360_wraps(double rawLon, double expected)
        {
            var lat = Angle.From(Degrees.FromRaw(10.5074));
            var lon = Angle.From(Degrees.FromRaw(rawLon));

            var point = new Geodesic(lat, lon);

            var expectedAngle = Angle.From(Degrees.FromRaw(expected));

            Assert.Equal(expectedAngle, point.Longitude);
        }
Exemple #9
0
        public void Can_convert_cartesian_to_spherical(double x, double y, double z, double phi, double theta, double r)
        {
            var point = new Cartesian3D(x, y, z);

            var result = Conversion.Spherical.From(point);

            var expected = new Spherical(
                phi: Angle.From(Degrees.FromRaw(phi)),
                theta: Angle.From(Degrees.FromRaw(theta)),
                r: r);

            Assert.Equal(expected, result);
        }
Exemple #10
0
        public void Can_convert_spherical_to_cartesian(double phi, double theta, double r, double x, double y, double z)
        {
            var spherical = new Spherical(
                phi: Angle.From(Degrees.FromRaw(phi)),
                theta: Angle.From(Degrees.FromRaw(theta)),
                r: r);

            var cartesian = Conversion.Cartesian3D.From(spherical);

            var expected = new Cartesian3D(x, y, z);

            Assert.Equal(expected, cartesian);
        }
Exemple #11
0
        public void Can_convert_spherical_to_geodesic(double phi, double theta, double r, double lat, double lon)
        {
            var point = new Spherical(
                phi: Angle.From(Degrees.FromRaw(phi)),
                theta: Angle.From(Degrees.FromRaw(theta)),
                r: r);

            var result = Conversion.Geodesic.From(point);

            var expected = new Geodesic(
                latitude: Angle.From(Degrees.FromRaw(lat)),
                longitude: Angle.From(Degrees.FromRaw(lon))
                );

            Assert.Equal(expected, result);
        }
Exemple #12
0
        private static void ProcessFiles(string inputPath, string outputPath)
        {
            var sw      = Stopwatch.StartNew();
            var results = File.ReadAllLines(inputPath)
                          .Select(ParseLine)
                          .Select(GetFullerPoint)
                          .Select(r => $"{r.X}, {r.Y}")
                          .ToList();

            Console.WriteLine($"Read {results.Count} lines from '{inputPath} in {sw.Elapsed.TotalSeconds:N2} seconds'");

            File.WriteAllLines(outputPath, results);

            Console.WriteLine($"Successfully wrote to '{outputPath}'");

            Geodesic ParseLine(string line)
            {
                var elements = line.Split(',');

                return(new Geodesic(Angle.From(Degrees.FromRaw(double.Parse(elements[1]))), Angle.From(Degrees.FromRaw(double.Parse(elements[0])))));
            }
        }
        public void Can_create_from_number(double n, double expected)
        {
            var degree = Degrees.FromRaw(n);

            Assert.Equal(expected, degree.Value);
        }
        public void Calculates_dymaxion_points_from_geodesic_correctly(double longitude, double latitude, double expectedX, double expectedY)
        {
            var point = new Geodesic(Angle.From(Degrees.FromRaw(latitude)), Angle.From(Degrees.FromRaw(longitude)));

            var result = GetFullerPoint(point);

            Assert.Equal(new Cartesian2D(expectedX, expectedY), result);
        }