Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Line.cs
===================================================================
diff -u -r4000 -r4052
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Line.cs (.../Line.cs) (revision 4000)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Line.cs (.../Line.cs) (revision 4052)
@@ -21,193 +21,192 @@
using System;
-namespace Deltares.DamEngine.Data.Geometry
+namespace Deltares.DamEngine.Data.Geometry;
+
+///
+/// Geometry Line, connecting begin point to end point with a straight line.
+///
+public class Line
{
+ private readonly Line line = new Line();
+
///
- /// Geometry Line, connecting begin point to end point with a straight line.
+ /// Initializes a new instance of the class.
///
- public class Line
+ public Line() : this(null, null) {}
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The begin point.
+ /// The end point.
+ public Line(Point2D beginPoint, Point2D endPoint)
{
- private readonly Line line = new Line();
+ BeginPoint = beginPoint;
+ EndPoint = endPoint;
+ }
- ///
- /// Initializes a new instance of the class.
- ///
- public Line() : this(null, null) {}
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The begin point.
- /// The end point.
- public Line(Point2D beginPoint, Point2D endPoint)
+ ///
+ /// Gets or sets the begin point.
+ ///
+ ///
+ /// The begin point.
+ ///
+ public Point2D BeginPoint
+ {
+ get
{
- BeginPoint = beginPoint;
- EndPoint = endPoint;
+ return line.Start;
}
-
- ///
- /// Gets or sets the begin point.
- ///
- ///
- /// The begin point.
- ///
- public Point2D BeginPoint
+ set
{
- get
- {
- return line.Start;
- }
- set
- {
- line.Start = value;
- }
+ line.Start = value;
}
+ }
- ///
- /// Gets or sets the end point.
- ///
- ///
- /// The end point.
- ///
- public Point2D EndPoint
+ ///
+ /// Gets or sets the end point.
+ ///
+ ///
+ /// The end point.
+ ///
+ public Point2D EndPoint
+ {
+ get
{
- get
- {
- return line.End;
- }
- set
- {
- line.End = value;
- }
+ return line.End;
}
-
- ///
- /// Creates the horizontal z line.
- ///
- /// The x1.
- /// The x2.
- /// The z.
- public void CreateHorizontalZLine(double x1, double x2, double z)
+ set
{
- SetBeginAndEndPoints(new Point2D
- {
- X = x1,
- Z = z
- }, new Point2D
- {
- X = x2,
- Z = z
- });
+ line.End = value;
}
+ }
- ///
- /// Sets the begin and end points.
- ///
- /// The begin point.
- /// The end point.
- public void SetBeginAndEndPoints(Point2D beginPoint, Point2D endPoint)
+ ///
+ /// Creates the horizontal z line.
+ ///
+ /// The x1.
+ /// The x2.
+ /// The z.
+ public void CreateHorizontalZLine(double x1, double x2, double z)
+ {
+ SetBeginAndEndPoints(new Point2D
{
- BeginPoint = beginPoint;
- EndPoint = endPoint;
- }
-
- ///
- /// Calculate intersection with another projected to the XZ plane.
- ///
- /// The other line segment.
- /// An intersection point in the XZ-plane, or null in case no intersection.
- public Point2D GetIntersectPointXz(Line other)
+ X = x1,
+ Z = z
+ }, new Point2D
{
- Point2D intersectionPoint;
- bool isIntersecting = line.IntersectsZ(other.line, out intersectionPoint);
+ X = x2,
+ Z = z
+ });
+ }
- return isIntersecting ? intersectionPoint : null;
- }
+ ///
+ /// Sets the begin and end points.
+ ///
+ /// The begin point.
+ /// The end point.
+ public void SetBeginAndEndPoints(Point2D beginPoint, Point2D endPoint)
+ {
+ BeginPoint = beginPoint;
+ EndPoint = endPoint;
}
///
- ///
+ /// Calculate intersection with another projected to the XZ plane.
///
- ///
- public class Line where T : Point2D, new()
+ /// The other line segment.
+ /// An intersection point in the XZ-plane, or null in case no intersection.
+ public Point2D GetIntersectPointXz(Line other)
{
- ///
- /// Initializes a new instance of the class.
- ///
- public Line() : this(null, null) {}
+ Point2D intersectionPoint;
+ bool isIntersecting = line.IntersectsZ(other.line, out intersectionPoint);
- ///
- /// Initializes a new instance of the class.
- ///
- /// The start.
- /// The end.
- public Line(T start, T end)
- {
- Start = start;
- End = end;
- }
+ return isIntersecting ? intersectionPoint : null;
+ }
+}
- ///
- /// Gets or sets the start.
- ///
- ///
- /// The start.
- ///
- public T Start { get; set; }
+///
+///
+///
+///
+public class Line where T : Point2D, new()
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Line() : this(null, null) {}
- ///
- /// Gets or sets the end.
- ///
- ///
- /// The end.
- ///
- public T End { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The start.
+ /// The end.
+ public Line(T start, T end)
+ {
+ Start = start;
+ End = end;
+ }
- ///
- /// Intersectses the z.
- ///
- /// The line.
- /// The intersection point.
- ///
- public bool IntersectsZ(Line line, out T intersectionPoint)
- {
- return Intersects(line, out intersectionPoint);
- }
+ ///
+ /// Gets or sets the start.
+ ///
+ ///
+ /// The start.
+ ///
+ public T Start { get; set; }
- private bool Intersects(Line line, out T intersectionPoint)
- {
- intersectionPoint = null;
+ ///
+ /// Gets or sets the end.
+ ///
+ ///
+ /// The end.
+ ///
+ public T End { get; set; }
- double dx1 = End.X - Start.X;
- double dx2 = line.End.X - line.Start.X;
+ ///
+ /// Intersectses the z.
+ ///
+ /// The line.
+ /// The intersection point.
+ ///
+ public bool IntersectsZ(Line line, out T intersectionPoint)
+ {
+ return Intersects(line, out intersectionPoint);
+ }
- double dyz1 = End.Z - Start.Z;
- double dyz2 = line.End.Z - line.Start.Z;
- double yz = Start.Z;
- double yzLine = line.Start.Z;
+ private bool Intersects(Line line, out T intersectionPoint)
+ {
+ intersectionPoint = null;
- double noem = dx1 * dyz2 - dyz1 * dx2;
- if (Math.Abs(noem) > 0.0)
+ double dx1 = End.X - Start.X;
+ double dx2 = line.End.X - line.Start.X;
+
+ double dyz1 = End.Z - Start.Z;
+ double dyz2 = line.End.Z - line.Start.Z;
+ double yz = Start.Z;
+ double yzLine = line.Start.Z;
+
+ double noem = dx1 * dyz2 - dyz1 * dx2;
+ if (Math.Abs(noem) > 0.0)
+ {
+ double u = (dx2 * (yz - yzLine) - dyz2 * (Start.X - line.Start.X)) / noem;
+ if ((u >= 0.0) && (u <= 1.0))
{
- double u = (dx2 * (yz - yzLine) - dyz2 * (Start.X - line.Start.X)) / noem;
- if ((u >= 0.0) && (u <= 1.0))
- {
- double v = (dx1 * (yz - yzLine) - dyz1 * (Start.X - line.Start.X)) / noem;
+ double v = (dx1 * (yz - yzLine) - dyz1 * (Start.X - line.Start.X)) / noem;
- if ((v >= 0.0) && (v <= 1.0))
+ if ((v >= 0.0) && (v <= 1.0))
+ {
+ intersectionPoint = new T
{
- intersectionPoint = new T
- {
- X = Start.X + u * dx1,
- Z = yz + u * dyz1
- };
- return true;
- }
+ X = Start.X + u * dx1,
+ Z = yz + u * dyz1
+ };
+ return true;
}
}
-
- return false;
}
+
+ return false;
}
}
\ No newline at end of file