コード例 #1
0
            static Shape <double> CreatePathShape(ConvolutionFactory factory)
            {
                var pathSegment = factory.CreateSegment(
                    startX: 0.0, startY: 0.0,
                    endX: 1.0, endY: 2.0,
                    weight: 1);

                var pathReverseSegment = factory.CreateSegment(
                    startX: 1.0, startY: 2.0,
                    endX: 0.0, endY: 0.0,
                    weight: 1);

                var smoothingArc1 = factory.CreateArc(
                    pathSegment.Start,
                    factory.CreateDirectionRange(
                        pathReverseSegment.Direction.NormalDirection().Opposite(),
                        pathSegment.Direction.NormalDirection().Opposite(),
                        Orientation.CounterClockwise),
                    0.0,
                    1);

                var smoothingArc2 = factory.CreateArc(
                    pathReverseSegment.Start,
                    factory.CreateDirectionRange(
                        pathSegment.Direction.NormalDirection().Opposite(),
                        pathReverseSegment.Direction.NormalDirection().Opposite(),
                        Orientation.CounterClockwise),
                    0.0,
                    1);

                return(factory.CreateShape(
                           new Tracing <double>[]
                           { smoothingArc1, pathSegment, smoothingArc2, pathReverseSegment }));
            }
コード例 #2
0
            static Shape <double> CreateDiskShape(ConvolutionFactory factory)
            {
                var eastDirection = factory.CreateDirection(1.0, 0.0);

                var diskArc = factory.CreateArc(
                    center: factory.CreatePoint(0.0, 0.0),
                    directions: factory.CreateDirectionRange(eastDirection, eastDirection, Orientation.CounterClockwise),
                    radius: 1.0,
                    weight: 1);

                return(factory.CreateShape(new[] { diskArc }));
            }
コード例 #3
0
        public void When_Direction_Ranges_Are_Included_Then_Intersection_Should_Be_The_Innermost_Range()
        {
            const double radius1 = 2.0;
            const double radius2 = 2.0;

            var convolutionFactory = new ConvolutionFactory();

            var arc1 = convolutionFactory.CreateArc(
                centerX: 1.0,
                centerY: 2.0,
                directionStartX: 1.0,
                directionStartY: 0.0,
                directionEndX: 0.0,
                directionEndY: 1.0,
                orientation: Orientation.CounterClockwise,
                radius: radius1,
                weight: 1);

            var arc2 = convolutionFactory.CreateArc(
                centerX: 2.0,
                centerY: 1.0,
                directionStartX: 1.0,
                directionStartY: 0.5,
                directionEndX: 0.5,
                directionEndY: 1.0,
                orientation: Orientation.CounterClockwise,
                radius: radius2,
                weight: 1);

            var convolution = convolutionFactory.ConvolveTracings(arc1, arc2).ToList();

            convolution.Should().HaveCount(1);

            convolution[0].Convolution.Should().BeOfType(typeof(Arc <double>));

            var convolutionAsArc = (Arc <double>)convolution[0].Convolution;

            convolutionAsArc.Center.Should().BeEquivalentTo(convolutionFactory.CreatePoint(3.0, 3.0));
        }
コード例 #4
0
        When_calling_ConvolveArcAndSegment_With_two_shapes_without_tangents_Then_the_result_Should_be_empty()
        {
            // Arrange arc1
            var arc = _factory.CreateArc(
                radius: 2.0,
                weight: 3,
                centerX: 1.0,
                centerY: 3.0,
                directionStartX: 2.0,
                directionStartY: 0.0,
                directionEndX: 0.0,
                directionEndY: 5.0,
                orientation: Orientation.CounterClockwise);

            // Arrange segment
            var segment = _factory.CreateSegment(
                startX: 10,
                startY: 5,
                endX: 15,
                endY: 10,
                weight: 4);

            // Act
            var actual = _factory.ConvolveArcAndSegment(arc, segment);

            // Assert
            actual.Should().BeEmpty();
        }