Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Calculation/Math2D.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Calculation/Math2D.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Calculation/Math2D.cs (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Ringtoets.Piping.Data.Properties;
+
+namespace Ringtoets.Piping.Data.Calculation
+{
+ ///
+ /// This class contains general mathematical routines for 2D lines.
+ ///
+ public static class Math2D
+ {
+ ///
+ /// Constant which is used to precision errors in comparisons.
+ ///
+ private const double epsilonForComparisons = 1e-8;
+
+ ///
+ /// Determines the intersection point of a line which passes through the and
+ /// the ; and a line which passes through the
+ /// and the .
+ ///
+ /// A which the first line passes through.
+ /// Another which the first line passes through.
+ /// A which the second line passes through.
+ /// Another which the second line passes through.
+ /// An with coordinates at the point where the lines intersect. Or null when no
+ /// intersection point exists (lines are parallel).
+ ///
+ /// Taken from: https://www.topcoder.com/community/data-science/data-science-tutorials/geometry-concepts-line-intersection-and-its-applications/
+ /// Based on https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
+ ///
+ /// Thrown when equals or
+ /// equals , which makes it impossible to determine
+ /// a line through the points.
+ public static Point2D LineIntersectionWithLine(Point2D line1Point1, Point2D line1Point2, Point2D line2Point1, Point2D line2Point2)
+ {
+ if (line1Point1.Equals(line1Point2) || line2Point1.Equals(line2Point2))
+ {
+ throw new ArgumentException(Resources.Math2D_LineIntersectionWithLine_Line_points_are_equal);
+ }
+
+ var aLine = line1Point2.Y - line1Point1.Y;
+ var bLine = line1Point1.X - line1Point2.X;
+ var cLine = aLine*line1Point1.X + bLine*line1Point1.Y;
+
+ var aOtherLine = line2Point2.Y - line2Point1.Y;
+ var bOtherLine = line2Point1.X - line2Point2.X;
+ var cOtherLine = aOtherLine*line2Point1.X + bOtherLine*line2Point1.Y;
+
+ var determinant = aLine*bOtherLine - aOtherLine*bLine;
+ if (Math.Abs(determinant) < epsilonForComparisons)
+ {
+ return null;
+ }
+
+ return new Point2D
+ {
+ X = (bOtherLine*cLine - bLine*cOtherLine)/determinant,
+ Y = (aLine*cOtherLine - aOtherLine*cLine)/determinant
+ };
+ }
+
+ ///
+ /// Determines the intersection points of a of with a vertical line
+ /// which is plotted at x=.
+ ///
+ /// A collection of segments that possibly intersect with the
+ /// vertical line at x=.
+ /// The x coordinate of the vertical line.
+ /// A of with all intersection points of the
+ /// with the vertical line at x=.
+ /// Segments which have length=0 or which are vertical, will not return an intersection point.
+ public static IEnumerable SegmentsIntersectionWithVerticalLine(IEnumerable segments, double verticalLineX)
+ {
+ var intersectionPointY = new Collection();
+
+ foreach (Segment2D segment in segments.Where(s => s.ContainsX(verticalLineX)))
+ {
+ Point2D intersectionPoint = LineIntersectionWithVerticalLine(segment.FirstPoint, segment.SecondPoint, verticalLineX);
+
+ if (intersectionPoint != null)
+ {
+ intersectionPointY.Add(intersectionPoint);
+ }
+ }
+
+ return intersectionPointY;
+ }
+
+ ///
+ /// Determines the intersection point of a line through the points and
+ /// with a vertical line at x=. If
+ /// equals , then no intersection point
+ /// will be returned.
+ ///
+ /// A which the line passes through.
+ /// Another which the line passes through.
+ /// The x coordinate of the vertical line.
+ /// The intersection point between the line through and
+ /// and the vertical line at x=; or null if
+ /// the line through and is vertical or
+ /// the points are equal.
+ private static Point2D LineIntersectionWithVerticalLine(Point2D point1, Point2D point2, double x)
+ {
+ var verticalLineFirstPoint = new Point2D
+ {
+ X = x,
+ Y = 0
+ };
+ var verticalLineSecondPoint = new Point2D
+ {
+ X = x,
+ Y = 1
+ };
+
+ try
+ {
+ return LineIntersectionWithLine(point1, point2, verticalLineFirstPoint, verticalLineSecondPoint);
+ }
+ catch (ArgumentException)
+ {
+ return null;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Exceptions/RingtoetsPipingSurfaceLineException.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Exceptions/RingtoetsPipingSurfaceLineException.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Exceptions/RingtoetsPipingSurfaceLineException.cs (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -0,0 +1,33 @@
+using System;
+
+namespace Ringtoets.Piping.Data.Exceptions
+{
+ ///
+ /// The exception that is thrown when operations on encounter
+ /// an error.
+ ///
+ public class RingtoetsPipingSurfaceLineException : Exception
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RingtoetsPipingSurfaceLineException(){}
+
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message.
+ ///
+ /// The error message that explains the reason for the exception.
+ public RingtoetsPipingSurfaceLineException(string message) : base(message){}
+
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message and a reference to the inner exception that is
+ /// the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception,
+ /// or a null reference if no inner exception is specified.
+ public RingtoetsPipingSurfaceLineException(string message, Exception inner) : base(message, inner) { }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Point2D.cs
===================================================================
diff -u -r2da86d14cee084c7d6bfa52136d387cdcdb0a025 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Point2D.cs (.../Point2D.cs) (revision 2da86d14cee084c7d6bfa52136d387cdcdb0a025)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Point2D.cs (.../Point2D.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -87,7 +87,7 @@
///
/// A to compare with.
/// True if the coordinates of the matches the coordinate of . False otherwise.
- protected bool Equals(Point2D other)
+ private bool Equals(Point2D other)
{
return X.Equals(other.X) && Y.Equals(other.Y);
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs
===================================================================
diff -u -r394db7c1bd905eb7444b9b2c47bcb5111bb63af6 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 394db7c1bd905eb7444b9b2c47bcb5111bb63af6)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18444
+// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -106,6 +106,25 @@
}
///
+ /// Looks up a localized string similar to Punten voor een lijn moeten uit elkaar liggen om een lijn te kunnen vormen..
+ ///
+ internal static string Math2D_LineIntersectionWithLine_Line_points_are_equal {
+ get {
+ return ResourceManager.GetString("Math2D_LineIntersectionWithLine_Line_points_are_equal", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Kan geen hoogte bepalen op het punt L={0}, omdate de dwarsdoorsnede verticaal loopt op dat punt..
+ ///
+ internal static string RingtoetsPipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l {
+ get {
+ return ResourceManager.GetString("RingtoetsPipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_verti" +
+ "cal_in_l", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Voor het maken van een segment zijn twee punten nodig..
///
internal static string Segment2D_Constructor_Segment_must_be_created_with_two_points {
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx
===================================================================
diff -u -r394db7c1bd905eb7444b9b2c47bcb5111bb63af6 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx (.../Resources.resx) (revision 394db7c1bd905eb7444b9b2c47bcb5111bb63af6)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx (.../Resources.resx) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -138,4 +138,10 @@
Gemiddelde moet groter zijn dan 0.
+
+ Punten voor een lijn moeten uit elkaar liggen om een lijn te kunnen vormen.
+
+
+ Kan geen hoogte bepalen op het punt L={0}, omdate de dwarsdoorsnede verticaal loopt op dat punt.
+
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj
===================================================================
diff -u -r394db7c1bd905eb7444b9b2c47bcb5111bb63af6 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision 394db7c1bd905eb7444b9b2c47bcb5111bb63af6)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -38,6 +38,9 @@
+
+ ..\..\..\..\lib\Plugins\Wti\Deltares.WTIPiping.dll
+ ..\..\..\..\packages\MathNet.Numerics.3.8.0\lib\net40\MathNet.Numerics.dllTrue
@@ -50,6 +53,8 @@
Properties\GlobalAssembly.cs
+
+
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs
===================================================================
diff -u -r5462a7ee52b9491f269d489a094d359f4f02f270 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 5462a7ee52b9491f269d489a094d359f4f02f270)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Double;
+using Ringtoets.Piping.Data.Calculation;
+using Ringtoets.Piping.Data.Exceptions;
+using Ringtoets.Piping.Data.Properties;
namespace Ringtoets.Piping.Data
{
@@ -64,6 +68,34 @@
}
///
+ /// Gets the height of the projected at a L=.
+ ///
+ /// The L coordinate from where to take the height of the .
+ /// The height of the at L=.
+ /// Thrown when the
+ /// intersection point at have a significant difference in their y coordinate.
+ public double GetZAtL(double l)
+ {
+ var projectGeometryToLz = ProjectGeometryToLZ().ToArray();
+ var segments = new Collection();
+ for (int i = 1; i < projectGeometryToLz.Length; i++)
+ {
+ segments.Add(new Segment2D(projectGeometryToLz[i-1], projectGeometryToLz[i]));
+ }
+
+ var intersectionPoints = Math2D.SegmentsIntersectionWithVerticalLine(segments, l).OrderBy(p => p.Y).ToArray();
+ var equalIntersections = Math.Abs(intersectionPoints.First().Y - intersectionPoints.Last().Y) < 1e-8;
+
+ if (equalIntersections)
+ {
+ return intersectionPoints.First().Y;
+ }
+
+ var message = string.Format(Resources.RingtoetsPipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l, l);
+ throw new RingtoetsPipingSurfaceLineException(message);
+ }
+
+ ///
/// Projects the points in to localized coordinate (LZ-plane) system.
/// Z-values are retained, and the first point is put a L=0.
///
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Segment2D.cs
===================================================================
diff -u -r72802865521b0ddd696ff95ab01573feb4bd0cb0 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Segment2D.cs (.../Segment2D.cs) (revision 72802865521b0ddd696ff95ab01573feb4bd0cb0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Segment2D.cs (.../Segment2D.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -59,7 +59,7 @@
/// true if the is vertical. false otherwise.
public bool IsVertical()
{
- return Math.Abs(FirstPoint.X - SecondPoint.X) < 1e-8 && !FirstPoint.Y.Equals(SecondPoint.Y);
+ return Math.Abs(FirstPoint.X - SecondPoint.X) < 1e-8 && Math.Abs(FirstPoint.Y - SecondPoint.Y) >= 1e-8;
}
///
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs
===================================================================
diff -u -r72802865521b0ddd696ff95ab01573feb4bd0cb0 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 72802865521b0ddd696ff95ab01573feb4bd0cb0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -4,7 +4,7 @@
using System.Linq;
using System.Linq.Expressions;
using Ringtoets.Piping.Data;
-using Ringtoets.Piping.IO.Calculation;
+using Ringtoets.Piping.Data.Calculation;
using Ringtoets.Piping.IO.Properties;
namespace Ringtoets.Piping.IO.Builders
Fisheye: Tag 712a020ea0330ece24849c2710641c1ce399ed61 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Calculation/Math2D.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r1efcd2277f5a38d44a78e4a9286eec35134fe8dd -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1efcd2277f5a38d44a78e4a9286eec35134fe8dd)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -178,15 +178,6 @@
}
///
- /// Looks up a localized string similar to Punten voor een lijn moeten uit elkaar liggen om een lijn te kunnen vormen..
- ///
- public static string Math2D_LineIntersectionWithLine_Line_points_are_equal {
- get {
- return ResourceManager.GetString("Math2D_LineIntersectionWithLine_Line_points_are_equal", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Kon profiel '{0}' niet opbouwen vanuit de gegevens uit de database..
///
public static string PipingSoilProfileReader_Could_not_build_profile_0_from_layer_definitions {
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx
===================================================================
diff -u -r1efcd2277f5a38d44a78e4a9286eec35134fe8dd -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 1efcd2277f5a38d44a78e4a9286eec35134fe8dd)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -189,9 +189,6 @@
Kritieke fout opgetreden bij het uitlezen van waarden uit kolommen in de database.
-
- Punten voor een lijn moeten uit elkaar liggen om een lijn te kunnen vormen.
-
Het XML document dat de geometrie beschrijft voor de laag is niet geldig.
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj
===================================================================
diff -u -r069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -47,7 +47,6 @@
-
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Calculation/Math2DTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Calculation/Math2DTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Calculation/Math2DTest.cs (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -0,0 +1,208 @@
+using System;
+using System.Collections;
+using System.Linq;
+using NUnit.Framework;
+using Ringtoets.Piping.Data.Calculation;
+
+namespace Ringtoets.Piping.Data.Test.Calculation
+{
+ [TestFixture]
+ public class Math2DTest
+ {
+ #region testcases
+
+ ///
+ /// Test cases for intersecting segments. The contains pairs of ,
+ /// which represent the coordinate of a point. Each pair of coordinates form a segment.
+ /// The last 2 double values are the expected intersection points.
+ ///
+ private static IEnumerable IntersectingSegments()
+ {
+ // \/
+ // /\
+ var testCaseDatadata1 = new TestCaseData(new[]
+ {
+ new Point2D(0.0,0.0),
+ new Point2D(1.0,1.0),
+ new Point2D(1.0,0.0),
+ new Point2D(0.0,1.0),
+ new Point2D(0.5,0.5)
+ }, "IntersectingSegments 1");
+ yield return testCaseDatadata1;
+
+ // __
+ // /
+ // /
+ var testCaseDatadata2 = new TestCaseData(new[]
+ {
+ new Point2D(0.0,0.0),
+ new Point2D(1.0,1.0),
+ new Point2D(0.0,1.0),
+ new Point2D(1.0,1.0),
+ new Point2D(1.0,1.0)
+ }, "IntersectingSegments 2");
+ yield return testCaseDatadata2;
+
+ //
+ // /
+ // /__
+ var testCaseDatadata3 = new TestCaseData(new[]
+ {
+ new Point2D(0.0,0.0),
+ new Point2D(1.0,0.0),
+ new Point2D(0.0,0.0),
+ new Point2D(1.0,1.0),
+ new Point2D(0.0,0.0)
+ }, "IntersectingSegments 3");
+ yield return testCaseDatadata3;
+ }
+
+ ///
+ /// Test cases for parallel segments. The contains pairs of ,
+ /// which represent the coordinate of a point. Each pair of coordinates form a segment.
+ ///
+ private static IEnumerable ParallelSegments()
+ {
+
+ // __
+ // __
+ var testCaseDatadata1 = new TestCaseData(new[]
+ {
+ new Point2D(0.0, 0.0),
+ new Point2D(1.0, 0.0),
+ new Point2D(0.0, 1.0),
+ new Point2D(1.0, 1.0)
+ }, "ParallelSegments");
+ yield return testCaseDatadata1;
+
+
+ // ____ (connected in single point)
+ var testCaseDatadata2 = new TestCaseData(new[]
+ {
+ new Point2D(0.0, 0.0),
+ new Point2D(1.0, 0.0),
+ new Point2D(1.0, 0.0),
+ new Point2D(2.0, 0.0)
+ }, "ParallelSegments, connected in single point");
+ yield return testCaseDatadata2;
+
+
+ // __ (overlap)
+ var testCaseDatadata3 = new TestCaseData(new[]
+ {
+ new Point2D(0.0, 0.0),
+ new Point2D(1.0, 0.0),
+ new Point2D(0.5, 0.0),
+ new Point2D(1.5, 0.0)
+ }, "ParallelSegments, overlap");
+ yield return testCaseDatadata3;
+ }
+
+ ///
+ /// Test cases for non intersecting segments. The contains pairs of ,
+ /// which represent the coordinate of a point. Each pair of coordinates form a segment.
+ ///
+ private static readonly Point2D[][] NonIntersectingSegments =
+ {
+ // |
+ // ___
+ new[]
+ {
+ new Point2D(0.0,0.0),
+ new Point2D(1.0,0.0),
+ new Point2D(0.5,1.0),
+ new Point2D(0.5,0.5),
+ new Point2D(0.5,0.0)
+ }
+ };
+
+ #endregion
+
+ [Test]
+ [TestCaseSource("IntersectingSegments")]
+ public void LineIntersectionWithLine_DifferentLineSegmentsWithIntersections_ReturnsPoint(Point2D[] points, string testname = "")
+ {
+ // Call
+ var result = Math2D.LineIntersectionWithLine(points[0], points[1], points[2], points[3]);
+
+ // Assert
+ Assert.AreEqual(points[4], result);
+ }
+
+ [Test]
+ [TestCaseSource("ParallelSegments")]
+ // String testname was added because the Teamcity report only counts the unique signatures that were tested
+ public void LineIntersectionWithLine_DifferentParallelLineSegments_ReturnsNoPoint(Point2D[] points, string testname="")
+ {
+ // Call
+ var result = Math2D.LineIntersectionWithLine(points[0], points[1], points[2], points[3]);
+
+ // Assert
+ Assert.IsNull(result);
+ }
+
+ [Test]
+ [TestCaseSource("NonIntersectingSegments")]
+ public void LineIntersectionWithLine_DifferentLineSegmentsWithNoIntersection_ReturnsPoint(Point2D[] points)
+ {
+ // Call
+ var result = Math2D.LineIntersectionWithLine(points[0], points[1], points[2], points[3]);
+
+ // Assert
+ Assert.AreEqual(points[4], result);
+ }
+
+ [Test]
+ public void LineIntersectionWithLine_WithEqualPoints_ThrowsArgumentException()
+ {
+ // Call
+ TestDelegate testA = () => Math2D.LineIntersectionWithLine(new Point2D(0,0), new Point2D(0,0), new Point2D(1,0), new Point2D(0,1));
+ TestDelegate testB = () => Math2D.LineIntersectionWithLine(new Point2D(0, 1), new Point2D(0, 0), new Point2D(1, 1), new Point2D(1, 1));
+
+ // Assert
+ var exceptionA = Assert.Throws(testA);
+ var exceptionB = Assert.Throws(testB);
+ Assert.AreEqual(Properties.Resources.Math2D_LineIntersectionWithLine_Line_points_are_equal, exceptionA.Message);
+ Assert.AreEqual(Properties.Resources.Math2D_LineIntersectionWithLine_Line_points_are_equal,exceptionB.Message);
+ }
+
+ [Test]
+ public void LineIntersectionWithLine_InterSectionsHigherUpX_ReturnsIntersectionWithTolerance()
+ {
+ // Setup
+ var y1 = 5.925;
+ var y2 = 5.890;
+ var start = 133;
+
+ // Call
+ var result = Math2D.LineIntersectionWithLine(new Point2D(start, y1), new Point2D(start + 1, y2), new Point2D(start + 0.5, 0), new Point2D(start + 0.5, 1));
+
+ // Assert
+ Assert.AreEqual((y1+y2)/2, result.Y, 1e-8);
+ }
+
+ [Test]
+ [TestCase(2.5, new [] {3.3})]
+ [TestCase(1.1, new double[0])]
+ [TestCase(5.5, new double[0])]
+ [TestCase(-1.5, new []{1.5, 3.75})]
+ public void SegmentsIntersectionWithVerticalLine_SegmentsCollectionNotIntersecting_ReturnsEmptyCollection(double x, double[] intersectionHeights)
+ {
+ // Setup
+ var segments = new[]
+ {
+ new Segment2D(new Point2D(2.2,3.3), new Point2D(3.3,3.3)),
+ new Segment2D(new Point2D(1.1,5.0), new Point2D(1.1,2.0)), // vertical
+ new Segment2D(new Point2D(5.5,2.0), new Point2D(5.5,2.0)), // no length
+ new Segment2D(new Point2D(-2.0,1.0), new Point2D(-1.0,2.0)),
+ new Segment2D(new Point2D(-1.0,2.0), new Point2D(-2.0,5.5))
+ };
+
+ // Call
+ var result = Math2D.SegmentsIntersectionWithVerticalLine(segments, x);
+
+ // Assert
+ Assert.AreEqual(intersectionHeights.Select(y => new Point2D(x, y)), result);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Exceptions/RingtoetsPipingSurfaceLineExceptionTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Exceptions/RingtoetsPipingSurfaceLineExceptionTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Exceptions/RingtoetsPipingSurfaceLineExceptionTest.cs (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -0,0 +1,70 @@
+using System;
+using NUnit.Framework;
+using Ringtoets.Piping.Data.Exceptions;
+
+namespace Ringtoets.Piping.Data.Test.Exceptions
+{
+ [TestFixture]
+ public class RingtoetsPipingSurfaceLineExceptionExceptionTest
+ {
+ [Test]
+ [SetCulture("en-US")]
+ public void DefaultConstructor_ExpectedValues()
+ {
+ // Call
+ var exception = new RingtoetsPipingSurfaceLineException();
+
+ // Assert
+ Assert.IsInstanceOf(exception);
+ var expectedMessage = string.Format("Exception of type '{0}' was thrown.", exception.GetType());
+ Assert.AreEqual(expectedMessage, exception.Message);
+ CollectionAssert.IsEmpty(exception.Data);
+ Assert.IsNull(exception.HelpLink);
+ Assert.IsNull(exception.InnerException);
+ Assert.IsNull(exception.Source);
+ Assert.IsNull(exception.StackTrace);
+ Assert.IsNull(exception.TargetSite);
+ }
+
+ [Test]
+ public void MessageConstructor_ExpectedValues()
+ {
+ // Setup
+ const string messageText = "";
+
+ // Call
+ var exception = new RingtoetsPipingSurfaceLineException(messageText);
+
+ // Assert
+ Assert.IsInstanceOf(exception);
+ Assert.AreEqual(messageText, exception.Message);
+ CollectionAssert.IsEmpty(exception.Data);
+ Assert.IsNull(exception.HelpLink);
+ Assert.IsNull(exception.InnerException);
+ Assert.IsNull(exception.Source);
+ Assert.IsNull(exception.StackTrace);
+ Assert.IsNull(exception.TargetSite);
+ }
+
+ [Test]
+ public void MessageAndInnerExceptionConstructor_ExpectedValues()
+ {
+ // Setup
+ var innerException = new Exception();
+ const string messageText = "";
+
+ // Call
+ var exception = new RingtoetsPipingSurfaceLineException(messageText, innerException);
+
+ // Assert
+ Assert.IsInstanceOf(exception);
+ Assert.AreEqual(messageText, exception.Message);
+ CollectionAssert.IsEmpty(exception.Data);
+ Assert.IsNull(exception.HelpLink);
+ Assert.AreEqual(innerException, exception.InnerException);
+ Assert.IsNull(exception.Source);
+ Assert.IsNull(exception.StackTrace);
+ Assert.IsNull(exception.TargetSite);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj
===================================================================
diff -u -r394db7c1bd905eb7444b9b2c47bcb5111bb63af6 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 394db7c1bd905eb7444b9b2c47bcb5111bb63af6)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -48,6 +48,8 @@
+
+
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs
===================================================================
diff -u -r5462a7ee52b9491f269d489a094d359f4f02f270 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 5462a7ee52b9491f269d489a094d359f4f02f270)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -3,6 +3,7 @@
using System.Linq;
using NUnit.Framework;
+using Ringtoets.Piping.Data.Exceptions;
namespace Ringtoets.Piping.Data.Test
{
@@ -157,6 +158,53 @@
}
[Test]
+ public void GetZAtL_SurfaceLineContainsPointAtL_ReturnsZOfPoint()
+ {
+ // Setup
+ var testZ = new Random(22).NextDouble();
+
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ var l = 2.0;
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D { X = 0.0, Y = 0.0, Z = 2.2 },
+ new Point3D { X = l, Y = 0.0, Z = testZ },
+ new Point3D { X = 3.0, Y = 0.0, Z = 7.7 },
+ });
+
+ // Call
+ var result = surfaceLine.GetZAtL(l);
+
+ // Assert
+ Assert.AreEqual(testZ, result);
+ }
+
+ [Test]
+ public void GetZAtL_SurfaceLineVerticalAtL_ThrowsRingtoetsPipingSurfaceLineException()
+ {
+ // Setup
+ var testZ = new Random(22).NextDouble();
+
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ var l = 2.0;
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D { X = 0.0, Y = 0.0, Z = 2.2 },
+ new Point3D { X = l, Y = 0.0, Z = testZ },
+ new Point3D { X = l, Y = 0.0, Z = testZ+1 },
+ new Point3D { X = 3.0, Y = 0.0, Z = 7.7 },
+ });
+
+ // Call
+ TestDelegate test = () => surfaceLine.GetZAtL(l);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ var message = string.Format(Properties.Resources.RingtoetsPipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l, l);
+ Assert.AreEqual(message, exception.Message);
+ }
+
+ [Test]
public void ToString_ReturnName()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Segment2DTest.cs
===================================================================
diff -u -rf69d756f50ae1464a1a11f0780b6d6aa646f3114 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Segment2DTest.cs (.../Segment2DTest.cs) (revision f69d756f50ae1464a1a11f0780b6d6aa646f3114)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Segment2DTest.cs (.../Segment2DTest.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -84,6 +84,37 @@
}
[Test]
+ [TestCase(1e-9, false)]
+ [TestCase(1e-8 + 1e-10, true)]
+ [TestCase(1e-8 - 1e-10, false)]
+ [TestCase(1e-7, true)]
+ [TestCase(1, true)]
+ public void IsVertical_DifferencesInY_ReturnsExpectedValue(double difference, bool isVertical)
+ {
+ // Setup
+ var random = new Random(22);
+ var x = random.NextDouble();
+ var y = random.NextDouble();
+ var firstPoint = new Point2D
+ {
+ X = x,
+ Y = y
+ };
+ var secondPoint = new Point2D
+ {
+ X = x,
+ Y = y+difference
+ };
+ var segment = new Segment2D(firstPoint, secondPoint);
+
+ // Call
+ var result = segment.IsVertical();
+
+ // Assert
+ Assert.AreEqual(isVertical, result);
+ }
+
+ [Test]
public void Equals_SameSegment_ReturnsTrue()
{
// Setup
Fisheye: Tag 712a020ea0330ece24849c2710641c1ce399ed61 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Calculation/Math2DTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj
===================================================================
diff -u -ra6ba313236d0ff8d2f219fc8249b700b1eade338 -r712a020ea0330ece24849c2710641c1ce399ed61
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision a6ba313236d0ff8d2f219fc8249b700b1eade338)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 712a020ea0330ece24849c2710641c1ce399ed61)
@@ -53,7 +53,6 @@
-