> For the complete documentation index, see [llms.txt](https://gitbook.testingwaters.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.testingwaters.in/geometry-1/boundary-curve.md).

# Boundary Curve

Closed curve connecting random points

![](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="/files/-LfT1duddBzbjCVdSDJd" %}

```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);
```
