Esempio n. 1
0
        public void Fast_ShouldSucceed()
        {
            Assert.True(InCirlce.Fast(
                            new double[] { 0, -1 },
                            new double[] { 0, 1 },
                            new double[] { 1, 0 },
                            new double[] { 0, 0 }) < 0);

            Assert.True(InCirlce.Fast
                            (new double[] { 0, -1 },
                            new double[] { 0, 1 },
                            new double[] { 1, 0 },
                            new double[] { -1, 0 }) == 0);

            Assert.True(InCirlce.Fast(
                            new double[] { 0, -1 },
                            new double[] { 0, 1 },
                            new double[] { 1, 0, },
                            new double[] { 10, 10 }) > 0);
        }
Esempio n. 2
0
        public void Fast_FromFile_ShouldSucceed()
        {
            double[] numbers =
                File.ReadAllLines("test_data/simple_data/incricle-poinst2d.txt")
                .Select(n => n.Split()).SelectMany(x => x)
                .Select(s => double.Parse(s)).ToArray();
            double[] results =
                File.ReadAllLines("test_data/simple_data/results-incircle.txt")
                .Select(n => n.Split()).SelectMany(x => x)
                .Select(s => double.Parse(s)).ToArray();

            int count = 0;

            for (int i = 0; i < NSimpleData; i += 8)
            {
                Assert.Equal(Math.Sign(results[count++]), Math.Sign(InCirlce.Fast(
                                                                        new double[] { numbers[i], numbers[i + 1] },
                                                                        new double[] { numbers[i + 2], numbers[i + 3] },
                                                                        new double[] { numbers[i + 4], numbers[i + 5] },
                                                                        new double[] { numbers[i + 6], numbers[i + 7] })));
            }
        }