Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
take into account slope at the end-points
Browse files Browse the repository at this point in the history
Extrapolating the Y-value horizontally leads to false positives for
curves with hight derivative twords the end of the curve.

Take the reference curve's slope when calculating tube's end-points.

Solves modelica-tools#13
  • Loading branch information
Elmir Jagudin committed Jul 15, 2016
1 parent d335141 commit 8f5a01b
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions Modelica_ResultCompare/CurveCompare/Algorithms/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,19 @@ private static Curve CalculateLower(Curve reference, TubeSize size)
// add point down left
LX.Add(reference.X[reference.Count - 1] - size.X);
LY.Add(reference.Y[reference.Count - 1] - size.Y);
}
// add point down right
LX.Add(reference.X[reference.Count - 1] + size.X);
LY.Add(reference.Y[reference.Count - 1] - size.Y);

// add point top right
LX.Add(reference.X[reference.Count - 1] + size.X);
// take into account the slope between last two points for Y value,
// to avoid false positive for curves with hight derivative twords the end
LY.Add(LY.Last() + (size.X * m0 * 2));
}
else
{
// add point down right
LX.Add(reference.X[reference.Count - 1] + size.X);
LY.Add(reference.Y[reference.Count - 1] - size.Y);
}
// -------------------------------------------------------------------------------------------------------------
// -------------- 2. Remove points and add intersection points in case of backward order -----------------------
// -------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -344,10 +352,19 @@ private static Curve CalculateUpper(Curve reference, TubeSize size)
// add point top left
UX.Add(reference.X[reference.Count - 1] - size.X);
UY.Add(reference.Y[reference.Count - 1] + size.Y);

// add point top right
UX.Add(reference.X[reference.Count - 1] + size.X);
// take into account the slope between last two points for Y value,
// to avoid false positive for curves with hight derivative twords the end
UY.Add(UY.Last() + (size.X * m0 * 2));
}
else
{
// add point top right
UX.Add(reference.X[reference.Count - 1] + size.X);
UY.Add(reference.Y[reference.Count - 1] + size.Y);
}
// add point top right
UX.Add(reference.X[reference.Count - 1] + size.X);
UY.Add(reference.Y[reference.Count - 1] + size.Y);

// ---------------------------------------------------------------------------------------------------------
// -------------- 2. Remove points and add intersection points in case of backward order -------------------
Expand Down

0 comments on commit 8f5a01b

Please sign in to comment.