Adjacency
Space Adjacency

Adjacency - Linear

1
//Sorting into three lists
2
nSrt=List.Reverse(List.Sort(n));
3
nSbL=List.Chop(nSrt,3);
4
lst1=List.Transpose(List.TakeEveryNthItem(nSbL,2,-1));
5
lst2=List.Transpose(List.Reverse((List.TakeEveryNthItem(nSbL,2,0))<1>));
6
7
//Three sublists with the sum of numbers more or less the same
8
lst3=(List.Transpose([List.Shuffle(lst1<1>),List.Shuffle(lst2<1>)]));
9
lst4 = List.Flatten(List.Clean(lst3,false)<1>,-1);
Copied!
1
r1=["Room1",ar1,ad1];
2
r2=["Room2",ar2,ad2];
3
r3=["Room3",ar3,ad3];
4
r4=["Room4",ar4,ad4];
5
r5=["Room5",ar5,ad5];
6
r6=["Room6",ar6,ad6];
7
r7=["Room7",ar7,ad7];
8
Rooms=[r1,r2,r3,r4,r5,r6,r7];
Copied!
1
//Sorting List By Adjacency Factor
2
IndexSrtByAdj=SortIndexByValue(List.GetItemAtIndex(Rooms<1>,2));
3
RoomsSrtByAdj=List.GetItemAtIndex(Rooms,IndexSrtByAdj);
4
5
//Circles
6
Circles=AdjL(List.GetItemAtIndex(RoomsSrtByAdj<1>,1));
7
Rms=Circles.ExtrudeAsSolid(Vector.ZAxis(),1);
8
Clr1=Color.ByARGB(255,255,0,0);
9
Clr2=Color.ByARGB(255,0,255,0);
10
Clr3=Color.ByARGB(255,0,0,255);
11
Clrs=[Clr1,Clr2,Clr3];
12
ClrI=0..1;
13
ClrV=0..1..#(List.Count(Rms));
Copied!
AdjacencyL.zip
6KB
Binary

Adjacency - Pairs

1
def AdjM(RmAr:var[])
2
{
3
return=[Imperative]
4
{
5
k=0;
6
rd=[];
7
cp=[];
8
ci=[];
9
dis=[];
10
cpd=[];
11
cpl=[];
12
cph=[];
13
cpx=[];
14
cpy=[];
15
16
for (i in RmAr)
17
{
18
if (k<2)
19
{
20
rd[k]=Math.Sqrt(i/Math.PI);
21
cp[0]=Point.Origin();
22
cp[k]=Point.ByCoordinates(rd[k]+rd[0],0);
23
ci[0]=Circle.ByCenterPointRadius(cp[0],rd[0]);
24
ci[k]=Circle.ByCenterPointRadius(cp[k],rd[k]);
25
k=k+1;
26
}
27
else
28
{
29
rd[k]=Math.Sqrt(i/Math.PI);
30
dis[k]=rd[k-2]+rd[k-1];
31
cpd[k]=Math.Sqrt(Math.Pow((cp[k-2].X-cp[k-1].X),2)+Math.Pow((cp[k-2].Y-cp[k-1].Y),2));
32
cpl[k]=(Math.Pow(rd[k-2]+rd[k],2)-Math.Pow(rd[k-1]+rd[k],2)+Math.Pow(cpd[k],2))/(cpd[k]*2);
33
cph[k]=Math.Sqrt(Math.Pow(rd[k-2]+rd[k],2)-Math.Pow(cpl[k],2));
34
cpx1[k]=(cpl[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])+(cph[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])+cp[k-2].X;
35
cpx2[k]=(cpl[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])-(cph[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])+cp[k-2].X;
36
cpy1[k]=(cpl[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])-(cph[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])+cp[k-2].Y;
37
cpy2[k]=(cpl[k]*(cp[k-1].Y-cp[k-2].Y)/cpd[k])+(cph[k]*(cp[k-1].X-cp[k-2].X)/cpd[k])+cp[k-2].Y;
38
if (cpy1[k]>=cpy2[k])
39
{
40
cpx[k]=cpx1[k];
41
cpy[k]=cpy1[k];
42
}
43
else
44
{
45
cpx[k]=cpx2[k];
46
cpy[k]=cpy2[k];
47
}
48
cp[k]=Point.ByCoordinates(cpx[k],cpy[k]);
49
ci[k]=Circle.ByCenterPointRadius(cp[k],rd[k]);
50
k=k+1;
51
}
52
}
53
return=ci;
54
}
55
};
Copied!
1
r1=["Room1",ar1,ad1];
2
r2=["Room2",ar2,ad2];
3
r3=["Room3",ar3,ad3];
4
r4=["Room4",ar4,ad4];
5
r5=["Room5",ar5,ad5];
6
r6=["Room6",ar6,ad6];
7
r7=["Room7",ar7,ad7];
8
Rooms=[r1,r2,r3,r4,r5,r6,r7];
Copied!
1
//Sorting List By Adjacency Factor
2
IndexSrtByAdj=List.SortIndexByValue(List.GetItemAtIndex(Rooms<1>,2));
3
RoomsSrtByAdj=List.GetItemAtIndex(Rooms,IndexSrtByAdj);
4
5
//Circles
6
Circles=AdjM(List.GetItemAtIndex(RoomsSrtByAdj<1>,1));
7
Rms=Circles.ExtrudeAsSolid(Vector.ZAxis(),1);
8
clrR=Math.RemapRange(Math.RandomList(List.Count(Rms)),0,200);
9
clrG=Math.RemapRange(Math.RandomList(List.Count(Rms)),0,200);
10
clrB=Math.RemapRange(Math.RandomList(List.Count(Rms)),0,200);
11
Clrs=Color.ByARGB(255,clrR,clrG,clrB);
12
ClrI=0..1..#(List.Count(Rms));
13
ClrV=Math.RemapRange(List.GetItemAtIndex(RoomsSrtByAdj<1>,2),0,1);
Copied!
AdjacencyM.zip
6KB
Binary
Last modified 1yr ago
Copy link
Contents