Exemplo n.º 1
0
        public void FromXToXY_WithReferencePointOffsetAndRotation_ReturnsCoordinatesFromReferencePoint()
        {
            // Setup
            const double center = 5.0;

            double[] xCoordinates =
            {
                center - Math.Sqrt(8),
                center,
                center + Math.Sqrt(2)
            };
            var          referencePoint = new Point2D(3, 4);
            const double offset         = 5;
            const double rotation       = 45;

            // Call
            IEnumerable <Point2D> points = AdvancedMath2D.FromXToXY(xCoordinates, referencePoint, offset, rotation);

            // Assert
            CollectionElementsAlmostEquals(new[]
            {
                new Point2D(1, 2),
                new Point2D(3, 4),
                new Point2D(4, 5)
            }, points);
        }
Exemplo n.º 2
0
        public void FromXToXY_NoPoints_ReturnsEmptyCollection()
        {
            // Call
            IEnumerable <Point2D> points = AdvancedMath2D.FromXToXY(new double[0], new Point2D(0, 0), 3, 2);

            // Assert
            CollectionAssert.IsEmpty(points);
        }
Exemplo n.º 3
0
 private static IEnumerable <Point2D> GetWorldPoints(ForeshoreProfile foreshoreProfile)
 {
     return(AdvancedMath2D.FromXToXY(
                foreshoreProfile.Geometry.Select(p => - p.X).ToArray(),
                foreshoreProfile.WorldReferencePoint,
                -foreshoreProfile.X0,
                foreshoreProfile.Orientation));
 }
 private static IEnumerable <Point2D> GetWorldPoints(DikeProfile dikeProfile)
 {
     return(AdvancedMath2D.FromXToXY(
                dikeProfile.DikeGeometry.Select(p => - p.Point.X),
                dikeProfile.WorldReferencePoint,
                -dikeProfile.X0,
                dikeProfile.Orientation));
 }
Exemplo n.º 5
0
        public void FromXToXY_WithoutReferencePoint_ThrowsArgumentNullException()
        {
            // Call
            void Call() => AdvancedMath2D.FromXToXY(new double[0], null, 3, 2);

            // Assert
            var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(
                Call, "Cannot transform to coordinates without a reference point.");

            Assert.AreEqual("referencePoint", exception.ParamName);
        }
Exemplo n.º 6
0
        public void FromXToXY_WithoutPoints_ThrowsArgumentNullException()
        {
            // Call
            void Call() => AdvancedMath2D.FromXToXY(null, new Point2D(0, 0), 3, 2);

            // Assert
            var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(
                Call, "Cannot transform to coordinates without a source.");

            Assert.AreEqual("xCoordinates", exception.ParamName);
        }
Exemplo n.º 7
0
        public void FromXToXY_WithRotation180_ReturnsCoordinatesOnNegativeYAxis()
        {
            // Setup
            double[] xCoordinates   = ThreeRandomXCoordinates();
            var      referencePoint = new Point2D(0, 0);

            // Call
            IEnumerable <Point2D> points = AdvancedMath2D.FromXToXY(xCoordinates, referencePoint, 0, 180);

            // Assert
            CollectionElementsAlmostEquals(xCoordinates.Select(x => new Point2D(0, -x)), points);
        }
Exemplo n.º 8
0
        public void FromXToXY_WithOffset_ReturnsCoordinatesNearerToOrigin()
        {
            // Setup
            double[] xCoordinates   = ThreeRandomXCoordinates();
            var      referencePoint = new Point2D(0, 0);
            int      offset         = new Random(21).Next();

            // Call
            IEnumerable <Point2D> points = AdvancedMath2D.FromXToXY(xCoordinates, referencePoint, offset, 0);

            // Assert
            CollectionElementsAlmostEquals(xCoordinates.Select(x => new Point2D(0, x - offset)), points);
        }
Exemplo n.º 9
0
        public void FromXToXY_WithReferencePoint_ReturnsCoordinatesFromReferencePoint()
        {
            // Setup
            var random = new Random(21);

            double[] xCoordinates   = ThreeRandomXCoordinates();
            var      referencePoint = new Point2D(random.NextDouble(), random.NextDouble());

            // Call
            IEnumerable <Point2D> points = AdvancedMath2D.FromXToXY(xCoordinates, referencePoint, 0, 0);

            // Assert
            CollectionElementsAlmostEquals(xCoordinates.Select(x => new Point2D(referencePoint.X, referencePoint.Y + x)), points);
        }