You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
so i did some more digging and got it to work by using a custom extension method for Polygon.GetParameterAt.
theres a few things ive noticed, but not sure if they are the culprit causing this behavior.
first the geometry in the rhino file is definitely not the best to test this on, since its a nurbs polycurve etc.
seems like there might be related to #945 , the closestPoint from DistanceTo does not seem to be always actually on the polygon. hence when using GetParameterAt using that point, it fails to find the segment the point lies on, returning -1.
GetParameterAt is not overriden on Polygon, so calls invoke the Polyline.Segments() instead of Polygon.Segments(), . maybe one less line in the return could be problematic.
heres a dirty workaround i used it make it work:
public static double PolygonGetParameterAt(this Polygon polygon, Vector3 point)
{
var segments = polygon.Segments();
var segment = segments.Select(s => new { line = s, dist = point.DistanceTo(point.ClosestPointOn(s)) }).OrderBy(p => p.dist).First().line;
var segmentIndex = segments.ToList().IndexOf(segment);
var segmentsLength = segments.Where((x, i) => i < segmentIndex).Sum(x => x.Length());
var pointLength = segmentsLength + point.ClosestPointOn(segment).DistanceTo(segment.Start);
return pointLength / polygon.Length();
}
ill try to save the geometry as json so we can test without the rhino3dm dependency.
See https://github.com/tkahng/ElementsCurve.
The text was updated successfully, but these errors were encountered: