Boundary Curve
Closed curve connecting random points
boundaryCurve.dyn
7KB
Text
1
//pts = Point.ByCoordinates(Math.RandomList(n)*53,Math.RandomList(n)*70,0);
2
pts = List.Flatten(Point.ByCoordinates((0..100..10)<1>,(0..100..10)<2>),-1);
3
def seq(pt:var[])
4
{
5
ct = Point.ByCoordinates(Math.Sum(pt.X)/List.Count(pt),
6
Math.Sum(pt.Y)/List.Count(pt));
7
qa = Math.Round(Vector.ByTwoPoints(ct,pt).Normalized().
8
AngleAboutAxis(Vector.YAxis(),Vector.ZAxis()));
9
q1 = List.GroupByKey(List.SortByKey(pt,qa)["sorted list"],
10
List.SortByKey(pt,qa)["sorted keys"])["groups"];
11
q2 = List.SortByKey(q1<1>,(Point.ByCoordinates(q1.X,q1.Y).
12
DistanceTo(ct))<1>)["sorted list"];
13
q3 = List.TakeEveryNthItem(q2,2,[1,0]);
14
q4 = List.Flatten(List.Transpose([List.FirstItem(q3),List.Reverse(List.LastItem(q3)<1>)]),-1);
15
return = q4;
16
};
17
pt1 = PolyCurve.ByPoints(seq(pts),true);
Copied!
Copy link