Adjacency

Space Adjacency

Adjacency - Linear

//Sorting into three lists
nSrt=List.Reverse(List.Sort(n));
nSbL=List.Chop(nSrt,3);
lst1=List.Transpose(List.TakeEveryNthItem(nSbL,2,-1));
lst2=List.Transpose(List.Reverse((List.TakeEveryNthItem(nSbL,2,0))<1>));

//Three sublists with the sum of numbers more or less the same
lst3=(List.Transpose([List.Shuffle(lst1<1>),List.Shuffle(lst2<1>)]));
lst4 = List.Flatten(List.Clean(lst3,false)<1>,-1);
r1=["Room1",ar1,ad1];
r2=["Room2",ar2,ad2];
r3=["Room3",ar3,ad3];
r4=["Room4",ar4,ad4];
r5=["Room5",ar5,ad5];
r6=["Room6",ar6,ad6];
r7=["Room7",ar7,ad7];
Rooms=[r1,r2,r3,r4,r5,r6,r7];
//Sorting List By Adjacency Factor
IndexSrtByAdj=SortIndexByValue(List.GetItemAtIndex(Rooms<1>,2));
RoomsSrtByAdj=List.GetItemAtIndex(Rooms,IndexSrtByAdj);

//Circles
Circles=AdjL(List.GetItemAtIndex(RoomsSrtByAdj<1>,1));
Rms=Circles.ExtrudeAsSolid(Vector.ZAxis(),1);
Clr1=Color.ByARGB(255,255,0,0);
Clr2=Color.ByARGB(255,0,255,0);
Clr3=Color.ByARGB(255,0,0,255);
Clrs=[Clr1,Clr2,Clr3];
ClrI=0..1;
ClrV=0..1..#(List.Count(Rms));

Adjacency - Pairs

def AdjM(RmAr:var[])
{
return=[Imperative]
{
k=0;
rd=[];
cp=[];
ci=[];
dis=[];
cpd=[];
cpl=[];
cph=[];
cpx=[];
cpy=[];

for (i in RmAr)
{
	if (k<2)
	{
		rd[k]=Math.Sqrt(i/Math.PI);
		cp[0]=Point.Origin();
		cp[k]=Point.ByCoordinates(rd[k]+rd[0],0);
		ci[0]=Circle.ByCenterPointRadius(cp[0],rd[0]);
		ci[k]=Circle.ByCenterPointRadius(cp[k],rd[k]);
		k=k+1;
	}
	else
	{
		rd[k]=Math.Sqrt(i/Math.PI);
		dis[k]=rd[k-2]+rd[k-1];
		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));
		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);
		cph[k]=Math.Sqrt(Math.Pow(rd[k-2]+rd[k],2)-Math.Pow(cpl[k],2));
		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;
		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;
		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;
		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;
		if (cpy1[k]>=cpy2[k])
		{
		cpx[k]=cpx1[k];
		cpy[k]=cpy1[k];
		}
		else
		{
		cpx[k]=cpx2[k];
		cpy[k]=cpy2[k];
		}
		cp[k]=Point.ByCoordinates(cpx[k],cpy[k]);
		ci[k]=Circle.ByCenterPointRadius(cp[k],rd[k]);
		k=k+1;
	}
}
return=ci;
}
};
r1=["Room1",ar1,ad1];
r2=["Room2",ar2,ad2];
r3=["Room3",ar3,ad3];
r4=["Room4",ar4,ad4];
r5=["Room5",ar5,ad5];
r6=["Room6",ar6,ad6];
r7=["Room7",ar7,ad7];
Rooms=[r1,r2,r3,r4,r5,r6,r7];
//Sorting List By Adjacency Factor
IndexSrtByAdj=List.SortIndexByValue(List.GetItemAtIndex(Rooms<1>,2));
RoomsSrtByAdj=List.GetItemAtIndex(Rooms,IndexSrtByAdj);

//Circles
Circles=AdjM(List.GetItemAtIndex(RoomsSrtByAdj<1>,1));
Rms=Circles.ExtrudeAsSolid(Vector.ZAxis(),1);
clrR=Math.RemapRange(Math.RandomList(List.Count(Rms)),0,200);
clrG=Math.RemapRange(Math.RandomList(List.Count(Rms)),0,200);
clrB=Math.RemapRange(Math.RandomList(List.Count(Rms)),0,200);
Clrs=Color.ByARGB(255,clrR,clrG,clrB);
ClrI=0..1..#(List.Count(Rms));
ClrV=Math.RemapRange(List.GetItemAtIndex(RoomsSrtByAdj<1>,2),0,1);

Last updated