Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs
===================================================================
diff -u -r6747 -r7071
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs (.../GeometryPointString.cs) (revision 6747)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/GeometryPointString.cs (.../GeometryPointString.cs) (revision 7071)
@@ -78,7 +78,7 @@
///
/// Matching distance where a point within this range is considered on the same point.
///
- private const double epsilon = GeometryConstants.Accuracy;
+ private const double epsilon = GeometryConstants.Tolerance;
///
/// The calculate points as protected field (to be able to prevent recursive calls to Points)
@@ -382,9 +382,8 @@
///
public Point2D DeterminePointAt(double x, double z)
{
- return points.FirstOrDefault(
- point => point.X.AlmostEquals(x, GeometryPoint.Precision) &&
- point.Z.AlmostEquals(z, GeometryPoint.Precision));
+ return points.FirstOrDefault(point => point.X.AlmostEquals(x, GeometryPoint.Precision) &&
+ point.Z.AlmostEquals(z, GeometryPoint.Precision));
}
///
@@ -493,6 +492,12 @@
return RelativeXzPosition.OnGeometricLine;
}
+ public RelativeXzPosition PositionXzOfPointRelatedToExtrapolatedLine(Point2D point,
+ ExtraPolationMode extraPolationMode = ExtraPolationMode.Beyond)
+ {
+ return IsPointConsideredBeyondLine(point, extraPolationMode) ? RelativeXzPosition.BeyondGeometricLine : DeterminePositionWithRespectToExtrapolatedLine(point, extraPolationMode);
+ }
+
///
/// Gets the surrounding rectangle around the geometry point string
///
@@ -552,12 +557,6 @@
return intersectionPointsWithLine;
}
- public RelativeXzPosition PositionXzOfPointRelatedToExtrapolatedLine(Point2D point,
- ExtraPolationMode extraPolationMode = ExtraPolationMode.Beyond)
- {
- return IsPointConsideredBeyondLine(point, extraPolationMode) ? RelativeXzPosition.BeyondGeometricLine : DeterminePositionWithRespectToExtrapolatedLine(point, extraPolationMode);
- }
-
private bool IsPointConsideredBeyondLine(Point2D point, ExtraPolationMode extraPolationMode)
{
if (Points.Count == 0)
@@ -578,11 +577,18 @@
{
double xToEvaluate = DetermineXToEvaluate(point, extraPolationMode);
double zAtX = GetZatX(xToEvaluate);
- if (Math.Abs(point.Z - zAtX) < 0.001)
+ if (Math.Abs(point.Z - zAtX) < GeometryConstants.Accuracy)
{
return RelativeXzPosition.OnGeometricLine;
}
+ // Look also at the horizontal distance between the point and the line in case of steep line
+ double xAtZ = GetXatZ(point.Z, point.X - 2 * GeometryConstants.Accuracy);
+ if (Math.Abs(point.X - xAtZ) < GeometryConstants.Accuracy)
+ {
+ return RelativeXzPosition.OnGeometricLine;
+ }
+
return point.Z <= zAtX ? RelativeXzPosition.BelowGeometricLine : RelativeXzPosition.AboveGeometricLine;
}
@@ -733,7 +739,7 @@
result.Add((1.0 - fraction) * current.Z + fraction * next.Z);
}
- // if both ofsets are negative the waterline goes back
+ // if both offsets are negative, the waterline goes back
if ((leftOffset < 0) && (rightOffset < 0))
{
double fraction = rightOffset / (rightOffset + leftOffset);
@@ -808,9 +814,8 @@
private static bool NoPointSameXzLocation(IEnumerable collection, Point2D point)
{
- return !collection.Any(
- p => Math.Abs(p.X - point.X) < GeometryConstants.Accuracy &&
- Math.Abs(p.Z - point.Z) < GeometryConstants.Accuracy);
+ return !collection.Any(p => Math.Abs(p.X - point.X) < GeometryConstants.Accuracy &&
+ Math.Abs(p.Z - point.Z) < GeometryConstants.Accuracy);
}
private List IntersectWithPointsListCore(IList list, bool closePointString)