Geometry from Image
imgTrace.zip
7KB
Binary
1
pntSeq(grpPnts(pts));
2
3
// Group Contiguous Points
4
def grpPnts(pts:var[]..[])
5
{
6
dis1 = pts<1>.DistanceTo(pts<2>)<2;
7
ind1 = List.AllIndicesOf(dis1<1>,true);
8
bln1 = true;
9
ind2 = [Imperative]
10
{
11
while (bln1)
12
{
13
cnt1 = List.Count(ind1);
14
ind1 = grpIndx(ind1);
15
cnt2 = List.Count(ind1);
16
bln1 = cnt2!=cnt1;
17
}
18
return = ind1;
19
}
20
pts1 = List.GetItemAtIndex(pts,ind2);
21
return = pts1;
22
};
23
24
def grpIndx(ind:var[]..[])
25
{
26
ind1 = List.SetIntersection(ind<1>,ind<2>);
27
cnt1 = List.Count(ind1<1><2>)>0;
28
ind2 = List.FilterByBoolMask(ind,cnt1<1>)["in"];
29
ind3 = List.UniqueItems(List.Flatten(ind2<1>,-1)<1>);
30
ind4 = List.UniqueItems(List.Sort(ind3<1>));
31
return = ind4;
32
};
33
34
def pntSeq(pnt:var[]..[])
35
{
36
c = Point.ByCoordinates(Math.Sum(pnt.X)/List.Count(pnt<1>),
37
Math.Sum(pnt.Y)/List.Count(pnt<1>));
38
a = (Vector.ByTwoPoints(c,pnt).Normalized()).AngleAboutAxis
39
(Vector.XAxis(),Vector.ZAxis());
40
p = List.SortByKey(pnt<1>,a<1>)["sorted list"];
41
return p;
42
43
};
Copied!
Last modified 1yr ago
Copy link