Ejemplo n.º 1
0
        public void CanGetOrientationsForLinearLines()
        {
            double       yMax;
            const double resol    = 0.0001;
            var          polyline = (IPolyline)CurveConstruction.StartLine(10, 0)
                                    .LineTo(15, 5)
                                    .Curve;

            Assert.AreEqual(2, TopologicalLineUtils.CalculateOrientation(polyline, resol,
                                                                         out yMax));

            polyline = (IPolyline)CurveConstruction.StartLine(15, 5)
                       .LineTo(10, 0)
                       .Curve;
            Assert.AreEqual(-2, TopologicalLineUtils.CalculateOrientation(polyline, resol,
                                                                          out yMax));

            polyline = (IPolyline)CurveConstruction.StartLine(10, 0)
                       .LineTo(15, 5)
                       .LineTo(10, 10)
                       .Curve;
            Assert.AreEqual(-1, TopologicalLineUtils.CalculateOrientation(
                                polyline, resol, out yMax));

            polyline = (IPolyline)CurveConstruction.StartLine(10, 10)
                       .LineTo(15, 5)
                       .LineTo(10, 0)
                       .Curve;
            Assert.AreEqual(1, TopologicalLineUtils.CalculateOrientation(
                                polyline, resol, out yMax));
        }
Ejemplo n.º 2
0
        public void SegmentsLinearToAnglePerformance()
        {
            IPolycurve line = CurveConstruction.StartLine(10, 10).LineTo(11, 15).Curve;

            for (var i = 0; i < _segmentPerformanceCount; i++)
            {
                double angle;
                TopologicalLineUtils.CalculateToAngle((ISegmentCollection)line, out angle);
            }
        }
Ejemplo n.º 3
0
        public void CanGetOrientationsForNonLinearLines()
        {
            const double resol = 0.0001;
            double       yMax;
            var          polyline = (IPolyline)CurveConstruction.StartLine(10, 0)
                                    .BezierTo(12, 2, 12, 4, 10, 6)
                                    .Curve;

            Assert.AreEqual(-1, TopologicalLineUtils.CalculateOrientation(polyline, resol,
                                                                          out yMax));
        }
Ejemplo n.º 4
0
        public void CanGetSegmentsAngle()
        {
            var line = (ISegmentCollection)CurveConstruction.StartLine(10, 10)
                       .LineTo(11, 15)
                       .Curve;
            double fromAngle;
            double toAngle;

            Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle));
            Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle));
            Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) < 1e-12);

            line = (ISegmentCollection)CurveConstruction.StartLine(10, 10)
                   .LineTo(11, 11)
                   .LineTo(12, 15)
                   .Curve;
            Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle));
            Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle));
            Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) > 1e-12);

            line = (ISegmentCollection)CurveConstruction.StartLine(10, 10)
                   .LineTo(10, 10)
                   .LineTo(11, 15)
                   .Curve;

            Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle));
            Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle));
            Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) < 1e-12);

            line = (ISegmentCollection)CurveConstruction.StartLine(10, 10)
                   .LineTo(10, 10)
                   .LineTo(10, 10)
                   .Curve;

            Assert.IsFalse(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle));
            Assert.IsFalse(TopologicalLineUtils.CalculateToAngle(line, out toAngle));

            line = (ISegmentCollection)CurveConstruction.StartLine(10, 10)
                   .BezierTo(10, 10, 11, 11, 11, 11)
                   .Curve;
            Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle));
            Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle));
            Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) < 1e-12);

            line = (ISegmentCollection)CurveConstruction.StartLine(10, 10)
                   .BezierTo(11, 10, 12, 11, 12, 12)
                   .Curve;
            Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle));
            Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle));
            Assert.IsTrue(Math.Abs(fromAngle) < 1e-12);
            Assert.IsTrue(Math.Abs(toAngle + Math.PI / 2) < 1e-12);
        }
Ejemplo n.º 5
0
        public void SegmentNonLinearToAnglePerformance()
        {
            IPolycurve line = CurveConstruction.StartLine(10, 10)
                              .BezierTo(11, 12, 11, 13, 12, 15)
                              .Curve;

            for (var i = 0; i < _segmentPerformanceCount; i++)
            {
                var      segs = (ISegmentCollection)line;
                ISegment seg  = segs.Segment[segs.SegmentCount - 1];
                double   angle;
                TopologicalLineUtils.CalculateToAngle(seg, out angle);
            }
        }