In Fact, all versions test OK.
_ed.WriteMessage($"IsPointOnPolyline: {IsPointOnPolyline(pline, wcspointOnPline)}\n");
_ed.WriteMessage($"IsPointOnCurveGDAP: {IsPointOnCurveGDAP((Curve)pline, wcspointOnPline)}\n");
_ed.WriteMessage($"IsPointOnCurveGCP: {IsPointOnCurveGCP((Curve)pline, wcspointOnPline)}\n");
// A generalized IsPointOnCurve function that works on all
// types of Curve (including PolyLines), but catches an
// Exception on failure
public static bool IsPointOnCurveGDAP(Curve cv, Point3d pt)
{
try
{ // Return true if operation succeeds
cv.GetDistAtPoint(pt);
return true;
}
catch { }
// Otherwise we return false
return false;
}
// A generalized IsPointOnCurve function that works on all
// types of Curve (including PolyLines), and checks the position
// of the returned point rather than relying on catching an
// exception
public static bool IsPointOnCurveGCP(Curve cv, Point3d pt)
{
try
{ // Return true if operation succeeds
Point3d p = cv.GetClosestPointTo(pt, false);
return ( p - pt ).Length <= Tolerance.Global.EqualPoint;
}
catch { }
// Otherwise we return false
return false;
}
public static bool IsPointOnPolyline(Polyline pl, Point3d pt)
{
bool isOn = false;
for (int i = 0; i < pl.NumberOfVertices; i++)
{
Curve3d seg = null;
SegmentType segType = pl.GetSegmentType(i);
if (segType == SegmentType.Arc)
seg = pl.GetArcSegmentAt(i);
else if (segType == SegmentType.Line)
seg = pl.GetLineSegmentAt(i);
if (seg != null)
{
isOn = seg.IsOn(pt);
if (isOn)
break;
}
}
return isOn;
}
From this I'd conclude that the fault is with your "Moving" code, not with these methods.
Regards,
// Called Kerry or kdub in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub
NZST UTC+12 : class keyThumper<T> : Lazy<T>; another Swamper