# Boundary Curve

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfT19RRaQ9cEvTGkr-h%2F-LfT1aOoGTzb2veXm_7b%2FboundaryCurve.gif?alt=media\&token=9452cbdf-7bbf-4716-940d-050947713d45)

{% file src="<https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfT19RRaQ9cEvTGkr-h%2F-LfT1duddBzbjCVdSDJd%2FboundaryCurve.dyn?alt=media&token=46326590-7d4c-40e8-854d-125811f45154>" %}

```d
//pts = Point.ByCoordinates(Math.RandomList(n)*53,Math.RandomList(n)*70,0);
pts = List.Flatten(Point.ByCoordinates((0..100..10)<1>,(0..100..10)<2>),-1);
def seq(pt:var[])
{
	ct = Point.ByCoordinates(Math.Sum(pt.X)/List.Count(pt),
	Math.Sum(pt.Y)/List.Count(pt));
	qa = Math.Round(Vector.ByTwoPoints(ct,pt).Normalized().
	AngleAboutAxis(Vector.YAxis(),Vector.ZAxis()));
	q1 = List.GroupByKey(List.SortByKey(pt,qa)["sorted list"],
	List.SortByKey(pt,qa)["sorted keys"])["groups"];
	q2 = List.SortByKey(q1<1>,(Point.ByCoordinates(q1.X,q1.Y).
	DistanceTo(ct))<1>)["sorted list"];
	q3 = List.TakeEveryNthItem(q2,2,[1,0]);
	q4 = List.Flatten(List.Transpose([List.FirstItem(q3),List.Reverse(List.LastItem(q3)<1>)]),-1);
	return = q4;
};
pt1 = PolyCurve.ByPoints(seq(pts),true);
```
