Exemplo n.º 1
0
        public void GetIntersectionPointsCircle_NoIntersection_SameX()
        {
            //assign
            WCircle a = new WCircle(new WPoint(-2, 0), 1);
            WCircle b = new WCircle(new WPoint(2, 0), 1);

            //act
            WPoint[] result = a.GetIntersectionPoints(b);
            //assert
            Assert.IsNull(result);
        }
Exemplo n.º 2
0
        public void GetIntersectionPointsCircle_SingleIntersection_SameX_DiffRadius()
        {
            //assign
            WCircle a = new WCircle(new WPoint(-2, 0), 2);
            WCircle b = new WCircle(new WPoint(1, 0), 1);

            //act
            WPoint[] result = a.GetIntersectionPoints(b);
            //assert
            Assert.AreEqual(1, result.Length);
            Assert.AreEqual(new WPoint(0, 0), result[0]);
        }
Exemplo n.º 3
0
        public void GetIntersectionPointsLine_VerticalLine_A()
        {
            //assign
            Geometry.MarginOfError = 0.01;
            WCircle a = new WCircle(new WPoint(53.8075, 29.1875), 4.6825) / Utilities.UNITS_TO_PIXELS;
            WLine   b = new WLine(new WPoint(51.27, 25), new WPoint(51.27, 19.125)) / Utilities.UNITS_TO_PIXELS;

            //account
            Utilities.SaveDiagram(new IDraw[] { a, b.ToLineSegment() }, nameof(TestCircle));
            //act
            WPoint[] result = a.GetIntersectionPoints(b);
            //assert
            Assert.AreEqual(2, result.Length);
        }
Exemplo n.º 4
0
        public void GetIntersectionPointsCircle_DoubleIntersection_SameX()
        {
            //assign
            WCircle a = new WCircle(new WPoint(-0.5, 0), 1);
            WCircle b = new WCircle(new WPoint(0.5, 0), 1);

            //act
            WPoint[] result    = a.GetIntersectionPoints(b);
            WPoint   minResult = (result[0] < result[1]) ? result[0] : result[1];
            WPoint   maxResult = (minResult == result[0]) ? result[1] : result[0];

            //assert
            Assert.AreEqual(2, result.Length);
            Assert.AreEqual(new WPoint(0, -0.5 * Math.Sqrt(3)), minResult);
            Assert.AreEqual(new WPoint(0, 0.5 * Math.Sqrt(3)), maxResult);
        }
Exemplo n.º 5
0
        public void GetIntersectionPointsLineSegment_DoubleIntersection()
        {
            //assign
            Geometry.MarginOfError = 0.01;
            //(x - 2)^2 + (y + 3)^2 = 4
            WCircle a = new WCircle(new WPoint(2, -3), 2);
            //2x + 2y = -1
            WLineSegment c = new WLineSegment(new WPoint(5, -11.0 / 2.0), new WPoint(0, -1.0 / 2.0));

            //account
            Utilities.SaveDiagram(new IDraw[] { a, c }, nameof(TestCircle));
            //act
            WPoint[] result    = a.GetIntersectionPoints(c);
            WPoint   minResult = (result[0] < result[1]) ? result[0] : result[1];
            WPoint   maxResult = (minResult == result[0]) ? result[1] : result[0];

            //assert
            Assert.AreEqual(2, result.Length);
            Assert.IsTrue(new WPoint(0.86, -1.36) == minResult);
            Assert.IsTrue(new WPoint(3.64, -4.14) == maxResult);
        }