public void RemoveSelfIntersectionsTest()
        {
            var geometry      = (ILucidLine)GeometryHelper.Create(File.ReadAllText("../../Data/selfIntersectingGeometry.json"));
            var fixedGeometry = LucidLine.Create(GeometryHelper.RemoveSelfIntersections(geometry));

            Assert.IsTrue(GeometryHelper.IsValid(fixedGeometry));
            Assert.IsFalse(GeometryHelper.SelfIntersects(fixedGeometry));

            geometry      = (ILucidLine)GeometryHelper.Create(File.ReadAllText("../../Data/selfIntersectingGeometry2.json"));
            fixedGeometry = LucidLine.Create(GeometryHelper.RemoveSelfIntersections(geometry));
            Assert.IsTrue(GeometryHelper.IsValid(fixedGeometry));
            Assert.IsFalse(GeometryHelper.SelfIntersects(fixedGeometry));
        }
        public void LengthTest()
        {
            var length = GeometryHelper.Length(LucidLine.Create(new IPoint[] {
                LucidPoint.Create(0, 0),
                LucidPoint.Create(1, 0),
                LucidPoint.Create(1, 2),
            }));

            Assert.AreEqual(3, length);

            length = GeometryHelper.Length(LucidLine.Create(new IPoint[] {
                LucidPoint.Create(0, 0),
                LucidPoint.Create(0, 5)
            }));

            Assert.AreEqual(5, length);
        }
        public void IntersectionLineTest()
        {
            var first = LucidLine.Create(new IPoint[] {
                new LucidPoint(0, 0), new LucidPoint(5, 5)
            });

            var second = LucidLine.Create(new IPoint[] {
                new LucidPoint(-1, 4), new LucidPoint(5, 0)
            });

            var intersection = GeometryHelper.LineIntersections(first, second).First();

            Assert.AreEqual(2, intersection.X);
            Assert.AreEqual(2, intersection.Y);

            second.Translate(-5, -5);
            var intersections = GeometryHelper.LineIntersections(first, second);

            Assert.AreEqual(0, intersections.Count());
        }
        public void SplitTest()
        {
            var first = LucidLine.Create(new IPoint[] {
                new LucidPoint(0, 0), new LucidPoint(5, 5), new LucidPoint(10, 9)
            });

            var second = LucidLine.Create(new IPoint[] {
                new LucidPoint(-1, 4), new LucidPoint(5, 0)
            });

            var parts = GeometryHelper.Split(first, second);

            Assert.AreEqual(2, parts.Count());
            Assert.AreEqual(2, parts.First().Vertices.Count());
            Assert.AreEqual(3, parts.ElementAt(1).Vertices.Count());

            second.Translate(-10, -10);
            parts = GeometryHelper.Split(first, second);

            Assert.AreEqual(1, parts.Count());
            Assert.AreEqual(3, parts.First().Vertices.Count());
        }