# Scrapbook

www\.testingwaters.net

{% tabs %}
{% tab title="Bicycle Station" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLhKi2Ecgql5nH9BtQ%2F-LhLhaZunk2SKYqjaxE0%2FBicycleStation2.jpg?alt=media\&token=e02b61a8-8940-4a91-a74a-dda3140bc808)
{% endtab %}

{% tab title="Bamiyan Cultural Center" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8r6fnF4YYbIgezX9D%2F-Lh8vlAoO1nCDHJ4mxjv%2FBamiyan-1.jpg?alt=media\&token=a357ffec-91a2-4acb-b3bd-106269e5a51a)
{% endtab %}

{% tab title="Guggenheim Helsinki" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQh-G7iqLWYB4hedfT%2F-LfQh8Iff-auQXqZoJEt%2FGH-8318189361-1.jpg?alt=media\&token=dec87725-a4df-4df9-86c7-da4601f085df)
{% endtab %}

{% tab title="NationalWarMuseum" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQfpR9j9hDcR1dLQuI%2FNWM-10.jpg?alt=media\&token=62b0ff35-fb60-4e9a-ab9b-cae5b19e0b38)
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Skewed Grid" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLzikCGGSdb7F7PjuN%2F-LhM0JbHpRDhwstzvzcC%2FSkewedSurfacePattern.png?alt=media\&token=a3395cc8-69e6-48c3-a8f0-df52d307b0d6)
{% endtab %}

{% tab title="Pattern" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQUJp_yIkmTIvwEt06%2F-LfQUgHRTw3C0JGNsq_E%2FPattern1.png?alt=media\&token=e6d9b2d6-873f-423b-aa08-3c1ef4ec61ec)
{% endtab %}

{% tab title="Layered Grid" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-3XbKxiPDDGlC7LT7%2F-Lg-4C_t47ytJMIyvykK%2FhexagonOnSurface.png?alt=media\&token=040e17e4-8556-443c-8a35-c1cf2f8cba8c)
{% endtab %}

{% tab title="Pattern" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQWY_J9NidhVDevh9l%2F-LfQWenj7sSCK_Ptbaz-%2FPattern2.png?alt=media\&token=d008c566-92b7-4aff-9f81-f193424a80a0)
{% endtab %}

{% tab title="Pattern" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLcLnFju9IDYZuh58y%2F-LhLcjOqSxQ-lOm1D4Pi%2Fpattern-1.jpg?alt=media\&token=d4906df8-622e-467f-b239-8b0ec9a055e1)
{% endtab %}

{% tab title="Waves" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-BiQlSQhSKUYshELs%2F-Lg-Bsrpk4oGFvHuL2j7%2Fwaves2.gif?alt=media\&token=e96b7a74-e06a-4378-9302-5143b0ccbd44)
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Adjacency" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLLyY3rj5qhkg38WZA%2F-LhLN76aCtUWxofAxFHA%2FAdjacencyStudy.jpg?alt=media\&token=4e9ed8c8-9f07-4bce-a4b1-2a8ac02af721)
{% endtab %}

{% tab title="Gyroid" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfT5dBcqGKkEfF_GwKq%2F-LfT5mvFcxhIRBdXxJCD%2FGyroid.png?alt=media\&token=08eab108-0525-45a2-983d-77840da9cb71)
{% endtab %}

{% tab title="Gherkin" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8laziipL6pQjdlbIT%2F-Lh8nq_8hDB2zIA2fd0e%2FphyllotacticGherkin.png?alt=media\&token=05c9251e-b17b-4d0d-8800-1280f8633b21)
{% endtab %}

{% tab title="Transformations" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLyFP3rAPFAfw0YfRG%2F-LhLzMSiGur6B8K7LQuh%2Fsphere.gif?alt=media\&token=f745feb0-f24c-4df6-854e-0bd6613d5a7a)
{% endtab %}

{% tab title="Hypotrochoid" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfT-gaWC3M6518JXr5a%2F-LfT-lL2xIwf8CkLJfAx%2FHypotrochoid.gif?alt=media\&token=456a19ff-bbf8-4e16-8180-0ae188bfc622)
{% endtab %}

{% tab title="Geodesic Sphere" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQPM1frdZgPCsZNGCY%2F-LfQPj8DqCVfGuz8envl%2FGeodesicSphere.png?alt=media\&token=1ac272c1-ec92-49a5-bb06-467137530a1f)
{% endtab %}

{% tab title="Funnel" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfTSYxbaTD3CRh2UnQO%2F-LfTSzDKwGMowMKiCtiC%2Fninebridges-1.png?alt=media\&token=ba68c1a3-7c91-4d47-bc2f-e878da0a6278)
{% endtab %}
{% endtabs %}


# Bamiyan Cultural Center

Design Competition

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8r6fnF4YYbIgezX9D%2F-Lh8vlAoO1nCDHJ4mxjv%2FBamiyan-1.jpg?alt=media\&token=a357ffec-91a2-4acb-b3bd-106269e5a51a)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh90N119Zj5XqfDYRxS%2FBamiyan-2.jpg?alt=media\&token=4491616d-b862-4aa1-aa17-7fa1fa8aeef9)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh90P4QH8XHNcmEdszM%2FBamiyan-3.jpg?alt=media\&token=bddab656-272e-4d36-96b0-a98a2686a760)


# Bauhaus Museum

Design Competition

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-30wO2S4qsqR1BS4%2Fbauhaus-1.jpg?alt=media\&token=09fd5977-fe7c-4211-b5bf-128117fc69a0)


# Better Hebbal

Urban Design Ideas Competition Entry

Hebbal located around 10 km from the Bangalore city is the gateway to the city from the airport. Currently, without strengthened public transportation serving this area, it is heavily reliant on private

\#ABetterHebbal Challenge invited citizens to bring about ideas for public transport adoption around the Hebbal rooted in strong belief that involving public in design thinking will not only get some out of the box ideas but also help build a momentum for adoption.

Ideas and concepts around increasing the adoption of Micro-mobility options to feed mass transport that are currently available and are being provisioned for the immediate future.

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FJ8zPp4EIDYlmg0ujARep%2FbetterHebbal%20-%20Sheet%20-%201%20-%20Interpolate.jpg?alt=media&amp;token=b78fd3a9-6491-4b02-a61f-35d28a155ee7" alt=""><figcaption><p>Interpolate</p></figcaption></figure>

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2F3RsiKVXwTirQv8Aeg7tS%2FbetterHebbal%20-%20Sheet%20-%202%20-%20Extrapolate.jpg?alt=media&amp;token=b531248a-73de-4ff4-a7a3-527e0c5b4818" alt=""><figcaption><p>Extrapolate</p></figcaption></figure>

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FpM6igIGXYt71kpNc8nEj%2FBetterHebbal.png?alt=media&amp;token=e9f91203-a571-4db9-848f-feaa71aa8163" alt=""><figcaption><p>Intrapolation &#x26; Extrapolation</p></figcaption></figure>

```d
wrd = [["Ward Name", "Area (sqkm)","Road Length (kms)","Lake Area (sqm)",
"Park Area (sqm)","Playground Area (sqm)","Bus Stops",
"Persons per sqkm","Decadal Population growth rate (%)"],
["Thanisandndra",10,235,444273,80829.49,1847,42,7,161,252.20],
["Byatarayanapura",10,144,308438,115449.12,19031,59,7,198,129.80],
["Kodigehalli",3.8,84,545611,166993.94,25810,16,12,369,119.80],
["Radhakrishna Temple Ward",1.9,54,80474,74683.61,9799,18,18,014,36.30],
["Sanjaya Nagar",1.5,44,0,37718.13,9231,9,21,096,34.40],
["Ganga Nagar",2.3,31,0,9386.52,15535,23,12,096,4.20],
["Hebbala",1.2,36,0,13100.59,13277,10,26,455,34.60],
["Vishwanath Nagenahalli",1.5,51,0,0,10540,8,34,772,100.80],
["Nagavara",2.1,65,0,0,0,14,29,205,71.50],
["Kaval Bairasandra",1.6,50,0,7208.17,3664,17,24,771,48.20],
["Manorayana Palya",0.8,33,0,2710.87,1996,5,59,123,37.80]];

mxWlkInt = 0.4;
mxBusInt = 0.6;
l = List.RestOfItems(wrd);
wrdArTtl = List.GetItemAtIndex(l<1>,1);
wrdArLak = List.GetItemAtIndex(l<1>,3);
wrdArPrk = List.GetItemAtIndex(l<1>,4);
wrdArPly = List.GetItemAtIndex(l<1>,5);
wrdRdLgt = List.GetItemAtIndex(l<1>,2);
wrdBsStp = List.GetItemAtIndex(l<1>,6);
wrdPlnDn = List.GetItemAtIndex(l<1>,7);
wrdPlnGw = List.GetItemAtIndex(l<1>,8);

//Ward Rectangles
wrdArEff = wrdArTtl-((wrdArLak + wrdArPrk + wrdArPly)*Math.Pow(10,-6));
wrdRctLg = (wrdBsStp/2)*mxBusInt;
wrdRctWd = wrdArEff/wrdRctLg;

//Required Stop/Station count
wrdRqStn = Math.Ceiling(wrdRdLgt/(mxWlkInt*2))-wrdBsStp;

//Unconnected Area
wrdOutWd = wrdRctWd>mxWlkInt?wrdRctWd-mxWlkInt:0;
wrdOutAr = wrdOutWd * wrdRctLg;
plDn2021 = (wrdPlnDn+(wrdPlnDn*wrdPlnGw/100));
wrdOutPn = Math.Ceiling(wrdOutAr * plDn2021);

wrdOutRd = wrdOutWd/wrdRctWd*wrdRdLgt;

//Required Stop/Station count
wrdOutSt = Math.Ceiling(wrdOutRd/(mxWlkInt*2));

//Population per station
stnOutPn = wrdOutPn==0?0:Math.Ceiling(wrdOutPn/wrdOutSt);

barStPt = Point.ByCoordinates(0,List.AddItemToFront(0,List.DropItems(Math.Sum(List.TakeItems(wrdRctWd+1,1..List.Count(wrdRctWd))),-1)));
barBsLn = Line.ByStartPointDirectionLength(barStPt,Vector.XAxis(),wrdRctLg);
barTpLn = barBsLn.Translate(Vector.YAxis(),wrdRctWd);

barBsPt = barBsLn.PointAtParameter(0..1..#Math.Ceiling(wrdRdLgt/wrdRctWd));

barInnWd = wrdRctWd<=0.4?wrdRctWd:0.4;
barOutWd = wrdRctWd>mxWlkInt?wrdRctWd-mxWlkInt:0;


barInnRd = Line.ByStartPointDirectionLength(barBsPt,Vector.YAxis(),barInnWd).Extrude(Vector.ZAxis(),wrdPlnDn/10000);
barOutRd = Line.ByStartPointDirectionLength(barBsPt.Translate(Vector.YAxis(),0.4),Vector.YAxis(),barOutWd).Extrude(Vector.ZAxis(),wrdPlnDn/10000);
List.Clean([barInnRd,barOutRd],false);
```

{% file src="/files/1Pjwr8i5c82bcOHFZ3WV" %}

{% file src="/files/NJfDU2JH3jXwV17vrRzt" %}


# Bicycle Station

T-Splines

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLhKi2Ecgql5nH9BtQ%2F-LhLhZTZMgfjGBkBJiFr%2FBicycleStation1.jpg?alt=media\&token=0604e29c-f98d-423b-871c-a5462dd71467)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLhKi2Ecgql5nH9BtQ%2F-LhLhaZunk2SKYqjaxE0%2FBicycleStation2.jpg?alt=media\&token=e02b61a8-8940-4a91-a74a-dda3140bc808)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLnDk3M9z0bBS-3AZa%2FbicycleStationDyn.jpg?alt=media\&token=d046713d-324b-4667-9a50-ed13c73eff77)

```d
[Line.ByStartPointEndPoint(Point.ByCoordinates(0.1,0,2.4),Point.ByCoordinates(2.9,2,2.4)),
Line.ByStartPointEndPoint(Point.ByCoordinates(2.9,2,2.4),Point.ByCoordinates(5.7,0,2.4)),
Line.ByStartPointEndPoint(Point.ByCoordinates(5.7,0,2.4),Point.ByCoordinates(0.1,0,2.4)),
Line.ByStartPointEndPoint(Point.ByCoordinates(0.1,0,0),Point.ByCoordinates(2.9,2,0)),
Line.ByStartPointEndPoint(Point.ByCoordinates(2.9,2,0),Point.ByCoordinates(5.7,0,0)),
Line.ByStartPointEndPoint(Point.ByCoordinates(5.7,0,0),Point.ByCoordinates(0.1,0,0)),
Line.ByStartPointEndPoint(Point.ByCoordinates(1.15,0.75,0),Point.ByCoordinates(1.15,0.75,2.4)),
Line.ByStartPointEndPoint(Point.ByCoordinates(2.9,2,0),Point.ByCoordinates(2.9,2,2.4)),
Line.ByStartPointEndPoint(Point.ByCoordinates(4.65,0.75,0),Point.ByCoordinates(4.65,0.75,2.4)),
Line.ByStartPointEndPoint(Point.ByCoordinates(0.75,0,0.6),Point.ByCoordinates(1.15,0.75,0.6)),
Line.ByStartPointEndPoint(Point.ByCoordinates(0.75,0,1.5),Point.ByCoordinates(1.15,0.75,1.5)),
Line.ByStartPointEndPoint(Point.ByCoordinates(2.525,1.25,0.6),Point.ByCoordinates(2.9,2,0.6)),
Line.ByStartPointEndPoint(Point.ByCoordinates(2.525,1.25,1.5),Point.ByCoordinates(2.9,2,1.5)),
Line.ByStartPointEndPoint(Point.ByCoordinates(4.265,0,0.6),Point.ByCoordinates(4.65,0.75,0.6)),
Line.ByStartPointEndPoint(Point.ByCoordinates(4.265,0,1.5),Point.ByCoordinates(4.65,0.75,1.5))];
```

```d
o1=Point.ByCoordinates(1,1.8,1.05);
x1=Vector.ByCoordinates(2.8,2);
y1=Vector.ByCoordinates(-0.581,0.814);
cs1=CoordinateSystem.ByOriginVectors(o1,x1,y1);
w=1.5;
l=1;
h=2.1;
b=true;
```

{% file src="/files/-LhLldji21vrzOveh-St" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLhKi2Ecgql5nH9BtQ%2F-LhLheP-e9j9H38dPXtq%2FBicycleStation3.jpg?alt=media\&token=eb7cd534-4559-459c-8599-011b69823e87)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLhKi2Ecgql5nH9BtQ%2F-LhLhgLSrvlQRMJGtkhF%2FBicycleStation4.jpg?alt=media\&token=907b2b5a-30bc-40a3-92ef-0daf1811a771)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLhKi2Ecgql5nH9BtQ%2F-LhLhiMnLxYcWc0vpoMS%2FBicycleStation5.jpg?alt=media\&token=a06ed21d-f67f-4a85-98be-b326b12d8ebc)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLhKi2Ecgql5nH9BtQ%2F-LhLhk7oA1HOPvc37LMa%2FBicycleStation6.jpg?alt=media\&token=bacfa2b0-d09d-4b40-b81b-ea31b829b39f)


# Cross Laminated Timber

CLT Structural Concept

![Concept and Construction](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MZM9lv1ne4y4mKF_NB9%2F-MZMEDDERVlG2Tk5Iaz5%2FCLT-01%20-%20Sheet%20-%201%20-%20C%20o%20n%20c%20e%20p%20t%20%20%20and%20%20%20C%20o%20n%20s%20t%20r%20u%20c%20t%20i%20o%20n.jpg?alt=media\&token=99b9f905-ecab-42e9-972c-ebcf4ea002cc)

![Climate and Community](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MZM9lv1ne4y4mKF_NB9%2F-MZMEI02Qs03Ay2M7Hj_%2FCLT-01%20-%20Sheet%20-%202%20-%20C%20l%20i%20m%20a%20t%20e%20%20%20and%20%20%20C%20o%20m%20m%20u%20n%20i%20t%20y.jpg?alt=media\&token=67c99579-38c4-4c27-a7e5-9ab32b07a97b)

{% file src="/files/-MZMF6SSaC8BA58bptmV" %}

### Burrow Borrow Barrow

Taking inspiration and material from trees, a purely CLT building system bearing a reduced physical and carbon footprint is conceived.<br>

**Burrow**<br>

Humanity has progressed by intelligently utilizing minerals obtained from burrowing the earth. We call it mining and it is the source of most raw materials used in buildings. Mining however expends gigantic amounts of energy while also inflicting substantial collateral damage to the natural environment.<br>

Tree roots also burrow the earth in search of minerals, they’ve been doing so for longer and with a lot more sophistication and finesse. Trees are major components of the biosphere, and their wood has a major role as a sustainable and renewable eco material. Their developing wood cells are one of the most important sinks for excess atmospheric CO2. Wood is the most important natural and endlessly renewable source of energy and has a major future role as an environmentally cost-effective and energy-sufficient material.<br>

**Borrow**<br>

‘The greenest building is the one that already exists’\*

Pursuing that line of thinking, if we unbuild an existing building it would be greener than the greenest, where the term unbuild alludes to harmonious dismantling and not violent demolition. Hypothetically travelling back to a time before the building existed would make it unbuilt. Greenest of the greenest.<br>

Unbuilt > Unbuild<br>

Any act of building is inherently environmentally unsustainable. The violence of excavation and the relative permanence of the foundation would have disrupted the topsoil and subterranean natural systems leaving it permanently scarred.<br>

The argument isn’t against buildings, but against a sense of ownership. Considering our relatively short existence on the planet, if we could behave like borrowers and consider it our fundamental obligation to return to nature the borrowed item in the condition it was received, we would be a lot more environmentally sustainable. In India, people are actually already culturally tuned to this philosophy. Construction projects usually begin with a worship ritual to take permission and seek forgiveness from Mother Earth for the disturbance of the earth’s equilibrium during construction.<br>

Unbuild -> Unbuilt<br>

The modular superstructure of the proposed building system with CLT panels can be completely dismantled and the significantly lower weight of CLT enables innovative foundation systems in structures within a certain scale to leave absolutely no trace once dismantled.<br>

#### Barrow

A wheelbarrow is one of the simplest complex machines, comprising two simple machines, the lever and wheel and axle working together making the task of moving loads easier. Redundancy is absent with every component serving a specific purpose at a specific position.<br>

Likewise, every component in the proposed CLT building system has a specific purpose. Here too redundant components or spaces are absent. Material cut out of larger flat panel modules are utilized as components in smaller multi-part circulation modules. Construction waste is effectively designed out from the start.<br>

Summarily, the concept heavily draws inspiration from it’s muse, the Papaya plant, with sustainable interpretations of the succulent hollow core, small footprint, uniform exposure and axial branching.<br>

{% file src="/files/-MZMFBp1T5RXvDJ-MdN9" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MZM9lv1ne4y4mKF_NB9%2F-MZMBjhCSqpB9qliwj31%2F20210302_2021-04-28_12-07-06.png?alt=media\&token=56fabe4f-b57b-48c0-a790-1d7151e6e075)

```d
armCnt = 10;
armExt = 3600;

flrThk = 100;
walThk = 100;
flrHgt = 3000;


rsrMax = 150;
rsrCnt = Math.Ceiling((flrThk + flrHgt)/rsrMax);
trdMin = 300;
strWdt = 1200;
elvWdt = 0;


creGap = 500;
armLgt = armExt - creGap - walThk;
crInLt = elvWdt + (strWdt*2) + (trdMin+(rsrCnt-1));
crInWt = elvWdt + (strWdt*2) + (trdMin+(rsrCnt-1));
creWal = creGap - (walThk*2);
creLgt = crInLt + creGap + walThk*2;
creWdt = crInWt + creGap + walThk*2;

dorWdt = 1000;
dorHgt = (flrHgt+flrThk)*0.75;


//Doors
dor001 = Rectangle.ByWidthLength(creWal+(walThk*4),dorWdt).Translate(creLgt/2,creLgt/2-dorWdt+(walThk*1.5),0).ExtrudeAsSolid(dorHgt);
dor002 = dor001.Rotate(Plane.XY(),0..#armCnt..90).Translate(Vector.ZAxis(),0..#armCnt..(flrHgt+flrThk)/4);

//Floors
flr001 = Rectangle.ByWidthLength(armLgt + dorWdt + walThk*2 - creWal*2,creWdt + armLgt + dorWdt + walThk*3).Translate(creLgt/2 + dorWdt/2 + walThk*1.5 + armLgt/2,-creWal+ walThk*1 + armLgt/2 + dorWdt/2,0).ExtrudeAsSolid(Vector.ZAxis(),-flrThk);
flr002 = flr001.Rotate(Plane.XY(),0..#armCnt+4..90).Translate(Vector.ZAxis(),0..#armCnt+4..(flrHgt+flrThk)/4);

//Panels
pnl001 = Solid.ByUnion(Line.ByStartPointDirectionLength(Point.ByCoordinates(-creLgt/2-creWal+(walThk/2),-creWdt/2-creWal),Vector.XAxis(),[creLgt+armLgt+dorWdt+walThk*2,creLgt+armLgt]).Extrude(Vector.ZAxis(),flrHgt).Thicken(walThk).Translate(Vector.YAxis(),[0,creWdt]));
pnl002 = pnl001.Rotate(Plane.XY(),0..#armCnt..90).Translate(Vector.ZAxis(),0..#armCnt..(flrHgt+flrThk)/4);
pnl003 = List.AddItemToEnd(List.LastItem(pnl002),pnl002.Difference(Solid.ByUnion(List.DropItems(pnl002,1..List.Count(pnl002)-1))));
pnl004 = pnl003.Difference(Solid.ByUnion(dor002));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MZM9lv1ne4y4mKF_NB9%2F-MZMBr1-WtbHqD6DZ2Ds%2F20210302B_2021-03-24_02-41-38.png?alt=media\&token=96800654-221a-4aba-b460-dbf6b1efb289)

```d
//flrCnt = 36;

//flrHgt = 3000;
//flrThk = 200;
//walThk = 200;

//Core cavity width
//corCav = 600;

//Entrance door width
entWdt = 1000;

//Extension from Core
//extLgt = 3200;

//Sunshade Depth
sunPrj = 750;

//Staircase
rsrMax = 180;
rsrCnt = Math.Ceiling((flrHgt/rsrMax)/4);
trdMin = 250;
//strWdt = 1200;

//Electrical Shaft
elcShf = 300;

//Elevator
//elvShf = 1800;
elvWdt = (elvShf*2) + (walThk*3) - ((rsrCnt-1)*trdMin);

//Core Interior Width
corInt = elvWdt + (strWdt*2) + (rsrCnt-1)*trdMin;

//Overall Exterior Width
extWid = corInt + corCav*2 + extLgt*2 + walThk*4;

//Start Elevation
strLvl = -0.75 * flrHgt;

//Floor Panel Count
lvlCnt = flrCnt + 5;

//Revit Element placement points
pnSpt1 = Point.ByCoordinates(-corInt/2 - walThk - corCav, -corInt/2 - walThk - corCav).Translate(Vector.YAxis(), [0,corCav + walThk*2 + corInt]);
pnSpt2 = pnSpt1<2>.Rotate(Plane.XY(),(0..#lvlCnt..90)<1>).Translate(Vector.ZAxis(),strLvl..#lvlCnt..(flrHgt)/4);
flSpt1 = Point.ByCoordinates(corInt/2 + walThk*2 + corCav, -corInt/2 - walThk*2 - corCav).Rotate(Plane.XY(),(0..#(lvlCnt + 3)..90)).Translate(Vector.ZAxis(),strLvl..#(lvlCnt+2)..(flrHgt)/4);
fcSpt1 = Point.ByCoordinates(-extWid/2,-extWid/2,0).Rotate(Plane.XY(),(0..#(lvlCnt-3)..90)).Translate(Vector.ZAxis(),0..#(lvlCnt-3)..(flrHgt)/4);
drSpt1 = Point.ByCoordinates(corInt/2,-corInt/2,0).Rotate(Plane.XY(),(0..#(lvlCnt-5)..90)).Translate(Vector.ZAxis(),0..#(lvlCnt-5)..(flrHgt)/4);
elSpt1 = Point.Origin().Translate(Vector.ZAxis(),flrThk..#flrCnt/4..flrHgt);

//Revit Foundation
fdnPn1 = FamilyType.ByName("Foundation").SetParameterByName(["Length", "Foundation Thickness", "Width"],[corInt + walThk*6 + corCav*2, 750, corInt + walThk*6 + corCav*2]);
fdnPn2 = FamilyInstance.ByPoint(FamilyType.ByName("Foundation"),Point.Origin());

//Revit Elevator Shaft
elvPn1 = FamilyType.ByName("elevatorModule").SetParameterByName(["Elevator Shaft Width", "Panel Height", "Panel Thickness"],[elvShf, flrHgt, walThk]);
elvPn2 = FamilyInstance.ByPoint(FamilyType.ByName("elevatorModule"),elSpt1);

//Revit Floor Panels
flrPn1 = FamilyType.ByName("floorPanel").SetParameterByName(["Floor Length", "Floor Thickness", "Floor Width"],[extLgt, flrThk, corInt + walThk*4 + corCav*2 + extLgt]);
flrPn2 = FamilyInstance.ByPoint(FamilyType.ByName("floorPanel"),List.DropItems(flSpt1,3)).SetRotation(List.DropItems(-(0..#(lvlCnt + 2)..90),3));

//Revit Door Modules
dorPn1 = FamilyType.ByName("doorModule").SetParameterByName(["Core Cavity", "Panel Height", "Door Width", "Panel Thickness", "Floor Thickness","Maximum Riser", "Minimum Tread", "Stair Width", "Elevator Shaft Width"],
[corCav, flrHgt, entWdt, walThk, flrThk, rsrMax, trdMin, strWdt, elvShf]);
dorPn2 = FamilyInstance.ByPoint(FamilyType.ByName("doorModule"),drSpt1).SetRotation(-(0..#(lvlCnt-5)..90));

//Revit Facade Panel
fcdPn1 = FamilyType.ByName("facadePanel").SetParameterByName(["Floor Height", "Overall Width", "Projection", "Thickness"],[flrHgt, extWid, sunPrj, flrThk]);
fcdPn2 = FamilyInstance.ByPoint(FamilyType.ByName("facadePanel"),List.DropItems(fcSpt1,0)).SetRotation(List.DropItems(-(0..#(lvlCnt-3)..90),0));

//Revit Wall Panels
walPn1 = FamilyType.ByName(["wallPanelLeft","wallPanelRight"])<1>.SetParameterByName(
["Core Cavity", "Core Length", "Door Width", "Extension Length", "Floor Thickness", "Panel Height", "Panel Thickness", "Electrical Shaft"]<2>,
[corCav, corInt, entWdt, extLgt, flrThk, flrHgt, walThk, elcShf]<2>);
walPn2 = FamilyInstance.ByPoint(FamilyType.ByName(["wallPanelLeft","wallPanelRight"]),pnSpt2<1>).SetRotation(-(0..#lvlCnt..90));
walPn3 = List.TakeItems(walPn2,3).SetParameterByName("Remove Bottom",-strLvl..#3..-flrHgt/4);
walPn4 = List.FirstItem(List.TakeItems(walPn2,-2)<1>).SetParameterByName("Remove Top",[flrHgt/4,3*flrHgt/4]);
walPn5 = List.LastItem(List.TakeItems(walPn2,-3)<1>).SetParameterByName("Remove Top",flrHgt/4..#3..flrHgt/4);
```

{% file src="/files/-MZMCHwnPzzydJJXioqo" %}
Dynamo version 2.12
{% endfile %}


# Facade

![Office Building Facade](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MRjZugR1loJoK9HvBLz%2F-MRj_8nisbmzSeDhKCrH%2F2021-AC01-01_2021-01-23_07-37-43.png?alt=media\&token=79c51183-0711-4f6b-a3b8-e13f6fdf7ada)

```d
//Bottom Curve West
bp1 = Plane.ByThreePoints(Point.ByCoordinates(-6,-10,0),Point.ByCoordinates(-6,6,2),Point.ByCoordinates(0,-10,0));
bc1 = NurbsCurve.ByPoints(Point.ByCoordinates([-7.5,-6,-5.5,-6,-7.5],[-12.5,-10,-4.5,1,3.5],2)).PullOntoPlane(bp1);

//Top Curve West
tp1 = Plane.ByThreePoints(Point.ByCoordinates(-6,-10,10.5),Point.ByCoordinates(-6,6.5,8.5),Point.ByCoordinates(0,-10,10.5));
tc1 = NurbsCurve.ByPoints(Point.ByCoordinates([-14.25,-6,-5.75,-7.5],[-11.75,-10,0.5,6.5],8.5)).PullOntoPlane(tp1);

//Vertical Curves
fc1 = NurbsCurve.ByPoints([bc1.StartPoint,Point.ByCoordinates(-10,-11,8),tc1.StartPoint]);
rc1 = NurbsCurve.ByPoints([bc1.EndPoint,Point.ByCoordinates(-7,4,8),tc1.EndPoint]);

ic1 = NurbsCurve.ByPoints([fc1.PointAtParameter(0.5),Point.ByCoordinates(-8.15,-11.5,5.75),rc1.PointAtParameter(0.5)]);

//MirrorPlane
mp1 = Plane.ByOriginNormal(Point.ByCoordinates(-0.5,0,0),Vector.XAxis());

//Surfaces
ls1 = Surface.ByLoft([bc1,ic1,tc1],[fc1,rc1]);
fc2 = NurbsCurve.ByPoints(List.Flatten([tc1.StartPoint,Point.ByCoordinates([-6,0.5,5.5],[-11.75,-11,-11.75],8.5),tc1.StartPoint.Mirror(mp1)],-1));
tc2 = fc2.Project(tp1,Vector.ZAxis());
ts1 = PolyCurve.ByJoinedCurves(List.Flatten([tc2,tc1,Line.ByStartPointEndPoint(tc1.EndPoint,tc1.Mirror(mp1).EndPoint),tc1.Mirror(mp1)],-1)).Patch();
rs1 = ls1.Mirror(mp1);
tc3 = Line.ByStartPointEndPoint(Point.ByCoordinates(14.625,-12.516,11.583),Point.ByCoordinates(-14.625,-12.516,11.583));
ts2 = Surface.ByLoft(List.Flatten([tc2,tc3],-1));
fs1 = tc3.Extrude(Vector.ZAxis(),23);
ps1 = PolySurface.ByJoinedSurfaces(List.Flatten([ls1,ts1,rs1,ts2,fs1],-1));
pl1 = Plane.ByOriginNormal(Point.ByCoordinates(7.5,3.5,2),Vector.ByCoordinates(0,-1,1)).Translate(Vector.ByCoordinates(0,-1,1),0..40..1);
pc1 = List.Clean(PolyCurve.ByJoinedCurves(ps1.Intersect(pl1)),false);
pc2 = List.AddItemToEnd(List.LastItem(pc1).Translate(0,4,3),pc1);
pt1 = List.Transpose(pc2<1>.PointAtParameter(0..1..#10));
nc1 = NurbsCurve.ByPoints(List.TakeEveryNthItem(pt1<1>,2,0),3);
sr1 = Surface.ByLoft(nc1);
pt2 = sr1<1>.PointAtParameter((0.1..0.825..#15)<2>,(0.15..0.85..#10)<3>);
nr1 = sr1<1>.NormalAtParameter((0.1..0.85..#15)<2>,(0.15..0.85..#10)<3>);
cr1 = Solid.ByUnion(List.Flatten(Circle.ByCenterPointRadiusNormal(pt2,0.75,nr1).Patch().Thicken(0.25),-1));
fd1 = sr1.SubtractFrom(cr1).Thicken(0.1);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MRjZugR1loJoK9HvBLz%2F-MRj_3TDcFjhZQ8lubAC%2F2021-AC01-01%20-%203D%20View%20-%20Front%20View.jpg?alt=media\&token=702c5a0b-ce5f-4898-a268-4a3f9c530201)

![Residence Remodeled](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLnQYAsMo8jLkvYVMY%2FBop1.jpg?alt=media\&token=1858301d-67bd-40aa-9ffd-8e15ff4180ec)

{% file src="/files/-LhM3DoHbWsGyKSv2zYJ" %}

```d
Msk1=Rm.GetParameterValueByName("Comments")=="Road Facing";
RmFil=Flatten(List.FilterByBoolMask(Rm,Msk1)["in"]);
RmNam=RmFil.GetParameterValueByName("Name");
RmSlGm=Flatten(RmFil.Geometry());
RmTnSh=RmSlGm.ThinShell(100,200);
Rms=Solid.ByUnion(Flatten([RmSlGm,RmTnSh]));

RmBb=((BoundingBox.ByGeometry(Rms)).ToCuboid()).Translate(Vector.YAxis(),-100);

//Determining the pivot point of cutting planes
RmsBb=BoundingBox.ByGeometry(Rms);
MnX=RmsBb.MinPoint.X;
MxX=RmsBb.MaxPoint.X;
MnY=RmsBb.MinPoint.Y;
MxY=RmsBb.MaxPoint.Y;
MnZ=RmsBb.MinPoint.Z;
MxZ=RmsBb.MaxPoint.Z;

//Three Lines at corners to create plane reference points
RfLn1=Line.ByStartPointEndPoint(Point.ByCoordinates(MnX,MnY,MnZ),Point.ByCoordinates(MxX,MnY,MnZ));
RfLn2=Line.ByStartPointEndPoint(Point.ByCoordinates(MnX,MnY,MxZ),Point.ByCoordinates(MxX,MnY,MxZ));
RfLn3=Line.ByStartPointEndPoint(Point.ByCoordinates(MnX,MxY,MnZ),Point.ByCoordinates(MxX,MxY,MnZ));

//RfPn1=Flatten({RfLn1,RfLn2,RfLn3})<1><2>.PointAtParameter(0..1..#VerDiv)<3>;
RfPn1=Flatten([RfLn1,RfLn2,RfLn3])<1><2>.PointAtParameter(
[0,0.05,0.1,0.15,0.25,0.30,0.365,0.45,0.58,0.62,0.75,0.785,0.915,0.975,1])<3>;
RfPn2=List.Flatten(RfPn1,1);
RfPl1=Plane.ByThreePoints(RfPn2[0],RfPn2[1],RfPn2[2]);

//Sweep Profile
RfSr1=Rms.Intersect(RfPl1);
RfCr1=RfSr1.PerimeterCurves();
RfMs1=(RfCr1.StartPoint.Y>=(MxY-100))&&(RfCr1.EndPoint.Y>=(MxY-100));
RfCr2=List.FilterByBoolMask(RfCr1,RfMs1)["out"];
RfMs2=(RfCr2.StartPoint.Z<=(MnZ+100))&&(RfCr2.EndPoint.Z<=(MnZ+100));
RfCr3=List.FilterByBoolMask(RfCr2,RfMs2)["out"];
RfCr4=Flatten(PolyCurve.ByJoinedCurves(RfCr3));
RfCr5=crvDir(RfCr4)[0]==crvDir(RfCr4)?RfCr4.Reverse():RfCr4;
RfCr6=List.DropItems(List.Sublists(RfCr5.StartPoint,0..1,1),-1);

l2=Transpose(RfCr6)[0].Translate(Vector.YAxis(),100);
RfCr7=Transpose([l2,Transpose(RfCr6)[1]]);
RfCr8=Line.ByBestFitThroughPoints(RfCr7);
RfCr9=PolyCurve.ByThickeningCurve(RfCr8,200,Vector.ZAxis());

//Creating the Exterior Solid Mass
ExSwCr=List.Reverse(RfCr9);
ExSwPr=List.DropItems((List.Reverse(RfCr5)),-1);
ExSwSl=Solid.ByUnion(Flatten((ExSwCr.SweepAsSolid(ExSwPr)).Intersect(RmBb)));
```

```d
//Graham scan to check line direction
//https://en.wikipedia.org/wiki/Graham_scan
def crvDir(crv:var){
p1=crv.PointAtParameter(0);
p2=crv.PointAtParameter(0.1);
p3=crv.PointAtParameter(1);
r=(p2.Y-p1.Y)*(p3.Z-p1.Z)-(p2.Z-p1.Z)*(p3.Y-p1.Y);
return=r==0?"colinear":(r<0?"clockwise":"counter clockwise");
};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLnNUNRLQDZ8fkfkhg%2FBop.jpg?alt=media\&token=53dc2263-bd37-467e-adee-2fe9f7b9163f)


# Flowing Fabrication

Fabrication

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLqi30xI5DC-zM_p__%2Fk1.jpg?alt=media\&token=c0b4b6b1-d3b4-476e-96ed-cfcb2b3aed85)

```d
pnts01 = Point.ByCoordinates(
[-0.98,-4.99,-11.28,-12,-15,-15,-15,-15,-15,-15,-14.5,-13,-11,-9,-6.5,-4]*304.8,
[-7.47,-9.86,-6.26,-6.26,-6.26,-9,-12,-16,-18,-19.5,-20,-20,-20,-20,-20,-19]*304.8,
[15.3,15.3,15.3,15.3,12.3,8,7,6.25,6,5.75,5.5,5,4.75,4.5,4.25,4]*304.8);

pnts02 = Point.ByCoordinates(
[-0.98,-4.99,-11.28,-12,-15,-15,-15,-15,-15,-15,-14.5,-13,-11,-9,-6.5,-4]*304.8,
[-7.47,-9.86,-6.26,-6.26,0.26,-4,-7,-11,-18,-19.5,-20,-20,-20,-20,-20,-19]*304.8,
[22.3,21.3,20.3,19.3,13.3,4,4,4,4,4,4,3,2,1,0.75,0.5]*304.8);

crv001 = NurbsCurve.ByPoints(pnts01);
crv002 = NurbsCurve.ByPoints(pnts02);

hrDvCt = 40;
vrDvCt = 3;
pnts03 = [crv001,crv002].PointsAtEqualChordLength((hrDvCt*2)-1);
pnts04 = [crv001,crv002].StartPoint;
pnts05 = [crv001,crv002].EndPoint;
pnts5A = List.AddItemToFront(pnts04<1>,pnts03<1>);
pnts06 = List.AddItemToEnd(pnts05<1>,pnts5A<1>);
lins01 = Line.ByStartPointEndPoint(pnts06[0],pnts06[1]);

srf001 = Surface.ByLoft(lins01);

pnts07 = lins01<1>.PointAtParameter(0..1..#(vrDvCt*4));

pnt111 = List.TakeEveryNthItem(pnts07,2,1);
pnt112 = List.Transpose(List.TakeEveryNthItem(pnt111<1>,4,[2,3])<1>);

pnt211 = List.TakeEveryNthItem(pnts07,2,0);
pnt212 = List.Transpose(List.TakeEveryNthItem(pnt211<1>,4,[1,0])<1>);

pnt311 = List.Flatten(List.Insert(pnt212<1><2>,pnt112<1><2>,1)<1>,-1);
pln311 = Plane.ByBestFitThroughPoints(pnt311);
pln312 = pln311.Translate(Vector.ByTwoPoints(pln311.Origin,List.FirstItem(pnt311<1>)));
cds312 = CoordinateSystem.ByPlane(pln312);
pnt312 = pnt311.Transform(cds312,CoordinateSystem.Identity());
pnt313 = Point.ByCoordinates(Math.Round(pnt312.X,2),Math.Round(pnt312.Y,2));
pnt314 = pnt313.Transform(CoordinateSystem.Identity(),cds312);
```

{% file src="/files/-LhLqcrz4JE5s83B\_z0h" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLnl_u-ueb6HCFBh47%2F2008-002-09.jpg?alt=media\&token=80f57603-219a-4019-874b-ccba44bea989)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLqmT_c7d2n_svYbER%2Fk2.jpg?alt=media\&token=cfd52837-e0d9-4ed9-8431-ee886370065c)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLqoMxj8bnTAAMQEX_%2Fk3.jpg?alt=media\&token=43cd9028-6b04-4eea-80ab-269976bc4bcd)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLqqQFRbE6-tZRNlTx%2Fk4.jpg?alt=media\&token=fa8a3106-16f3-443f-afcf-fa78ad3b962d)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLn50bMIV6HES8VmZZ%2F-LhLqtArqrL9_EDwkDwt%2Fk5.jpg?alt=media\&token=6e1288e6-851e-4dc1-a59e-f9094e92a5bf)


# Form from Images

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-hV8wmXWZbLmihAa%2Fses.jpg?alt=media\&token=29d22c59-0ffa-4535-af8d-3e65b3b3b264)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-oUiV4Losd6QGvZf%2F02.jpg?alt=media\&token=e8360122-55af-45a6-8420-e681131c8926)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-txFDtM3hxvHiCfy%2F08.jpg?alt=media\&token=d84183ae-0d12-42e6-8ac8-9fcc8b863bfd)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-w2X2QDMxNWQcVDn%2F05a.jpg?alt=media\&token=c0f6afc2-6dc7-4ace-b2e8-9a3ced397dc2)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-xrys64FGrteeSkB%2F06.jpg?alt=media\&token=83184e74-3526-418d-8aca-f12ecf5f9dd2)


# Guggenheim Helsinki

The building should be designed so as to fit into its surroundings.\
In cityscape and landscape impact, the design should be located so as to not obscure views from Tahitornin vuori park **past and over the building**

| Aeriel View                                                                                                                                                                                                          | Site View                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ![0:2](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Ld8QL1ZHEqwmklixk5T%2F-Ld8QNgV2tAycbIBVC5O%2FAerielView1.png?generation=1556010078542173\&alt=media) | ![1:2](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Ld8QL1ZHEqwmklixk5T%2F-Ld8QNgXV_sI6Gm6-_vF%2FSiteView1.png?generation=1556010078484525\&alt=media) |

```d
//Vantage Point
Peak=Point.ByCoordinates(-552,-77,27.5);

//A list of the xyz coordinates of the points along the site boundary
portX = {-556,-530,-528,-516,-518,-481,-480,-462,-384,-385,-380,
-380,-385,-386,-358,-358,-277,-273,-257,-246,-6};
portY = {544,546,517,518,546,548,520,500,505,520,520,532,532,549,
550,553,557,458,447,464,302};
portZ = -10;
portVer = Point.ByCoordinates(portX,portY,portZ);
portEdg = PolyCurve.ByPoints(portVer,false);
```

| 0:0                                                                                                                                                                                                             | 1:0 |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- |
| ![0:2](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Ld8QL1ZHEqwmklixk5T%2F-Ld8QNgZVUMgRZGU-PPB%2FDyn-01.png?generation=1556010078573222\&alt=media) | 1:2 |

{% file src="/files/-LhLF3LCvtdRBzzgVoK8" %}

```d
GridDensity=2;

//Far Port Profile
PortVertices=[Imperative]
{
//Elevation, considering a level site
e2=-10;
//A list of the xyz coordinates of the points along the site boundary
Coordinates={-556,544,e2,-530,546,e2,-528,517,e2,-516,518,e2,-518,546,e2,-481,548,e2,-480,520,e2,-462,500,e2,-384,505,e2,-385,520,e2,-380,520,e2,-380,532,e2,-385,532,e2,-386,549,e2,-358,550,e2,-358,553,e2,-277,557,e2,-273,458,e2,-257,447,e2,-246,464,e2,-6,302,e2};
//Creating points from the list of xyz coordinates
Points={};
pi=0;
pc=0;
while (pc<List.Count(Coordinates))
{
Points[pi]=Point.ByCoordinates(Coordinates[pc],Coordinates[pc+1],Coordinates[pc+2]);
pi=pi+1;
pc=pc+3;
}
return=Points;
}
//Connecting points with lines
PortEdge=PolyCurve.ByPoints(PortVertices,false);

VolumetricMass=[Imperative]
{
//Elevation, considering a level site
e1=2.1;
//A list of the xyz coordinates of the points along the site boundary
Coordinates={-535,270,e1,-471,274,e1,-470,253,e1,-442,219,e1,-428,202,e1,-418,189,e1,-366,126,e1,-439,65,e1,-470,107,e1,-476,115,e1,-484,125,e1,-490,134,e1,-493,138,e1,-497,143,e1,-504,154,e1,-511,166,e1,-517,177,e1,-521,187,e1,-525,199,e1,-529,211,e1,-532,224,e1,-534,239,e1,-535,244,e1,-536,250,e1};
//Creating points from the list of xyz coordinates
Points={};
pi=0;
pc=0;
while (pc<List.Count(Coordinates))
{
Points[pi]=Point.ByCoordinates(Coordinates[pc],Coordinates[pc+1],Coordinates[pc+2]);
pi=pi+1;
pc=pc+3;
}

//Connecting points with lines
SiteBoundary=PolyCurve.ByPoints(Points,true);

//West Deduction Profile
//A list of the xyz coordinates of the points along the site boundary
WestDeductionCoordinates={-535,270,e1,-525,271,e1,-526,250,e1,-525,245,e1,-525,240,e1,-522,226,e1,-519,214,e1,-516,202,e1,-511,191,e1,-507,181,e1,-502,170,e1,-495,159,e1,-489,149,e1,-485,144,e1,-481,139,e1,-476,131,e1,-468,121,e1,-462,113,e1,-452,99,e1,-432,72,e1,-431,71,e1,-439,64,e1,-439,65,e1,-470,107,e1,-476,115,e1,-484,125,e1,-490,134,e1,-493,138,e1,-497,143,e1,-504,154,e1,-511,166,e1,-517,177,e1,-521,187,e1,-525,199,e1,-529,211,e1,-532,224,e1,-534,239,e1,-535,244,e1,-536,250,e1};
//Creating points from the list of xyz coordinates
WestDeductionPoints={};
pi=0;
pc=0;
while (pc<List.Count(WestDeductionCoordinates))
{
WestDeductionPoints[pi]=Point.ByCoordinates(WestDeductionCoordinates[pc],WestDeductionCoordinates[pc+1],WestDeductionCoordinates[pc+2]);
pi=pi+1;
pc=pc+3;
}
//Connecting points with lines
WestDeductionLines=PolyCurve.ByPoints(WestDeductionPoints,true);
WestDeduction=WestDeductionLines.ExtrudeAsSolid(Vector.ByCoordinates(0,0,1),5.5);

//East Deduction Profile
//A list of the xyz coordinates of the points along the East boundary
EastDeductionCoordinates={-485,274,e1,-470,274,e1,-469,253,e1,-441,219,e1,-433,209,e1,-427,202,e1,-417,189,e1,-377,141,e1,-397,140,e1,-429,180,e1,-440,192,e1,-446,200,e1,-454,209,e1,-485,247,e1};
//Creating points from the list of xyz coordinates
EastDeductionPoints={};
qi=0;
qc=0;
while (qc<List.Count(EastDeductionCoordinates))
{
EastDeductionPoints[qi]=Point.ByCoordinates(EastDeductionCoordinates[qc],EastDeductionCoordinates[qc+1],EastDeductionCoordinates[qc+2]);
qi=qi+1;
qc=qc+3;
}
//Connecting points with lines
EastDeductionLines=PolyCurve.ByPoints(EastDeductionPoints,true);
EastDeduction=EastDeductionLines.ExtrudeAsSolid(Vector.ByCoordinates(0,0,1),25);

//Volumetric Mass
SiteMass=SiteBoundary.ExtrudeAsSolid(-22);
Deductions={WestDeduction,EastDeduction};
Deduction=Deductions[0].UnionAll(Deductions);
SiteMass=SiteMass.Difference(Deduction);
return=SiteMass;
}

//Sight Lines from Park to Far Port
ParkSightLines=[Imperative]
{
Peak=Point.ByCoordinates(-552,-77,27.5);

//Elevation, considering a level site
e2=-15;
//A list of the xyz coordinates of the points along the site boundary
Coordinates={-556,544,e2,-530,546,e2,-528,517,e2,-516,518,e2,-518,546,e2,-481,548,e2,-480,520,e2,-462,500,e2,-384,505,e2,-385,520,e2,-380,520,e2,-380,532,e2,-385,532,e2,-386,549,e2,-358,550,e2,-358,553,e2,-277,557,e2,-273,458,e2,-257,447,e2,-246,464,e2,-6,302,e2};
//Creating points from the list of xyz coordinates
Points={};
pi=0;
pc=0;
while (pc<List.Count(Coordinates))
{
Points[pi]=Point.ByCoordinates(Coordinates[pc],Coordinates[pc+1],Coordinates[pc+2]);
pi=pi+1;
pc=pc+3;
}

//Angles Connecting Peak to Port Edge
Angles={};
ai=0;
while (ai<List.Count(Points))
{
Angles[ai]=Math.Atan((Points[ai].X-Peak.X)/(Points[ai].Y-Peak.Y));
ai=ai+1;
}

//Lines Connecting Peak to Port Edge
EPoints={};
li=0;
lc=1;
EPoints[0]=Points[0];
while (li<(List.Count(Points)-1))
{
if (Angles[li+1]>(Angles[li]+0.5))
{
EPoints[lc]=Points[li+1];
li=li+1;
lc=lc+1;
}
else
{
li=li+1;
}
}
//Polycurves
PLines={};
PExt={};
di=0;
while (di<(List.Count(EPoints)-1))
{
PPoints={Peak,EPoints[di],EPoints[di+1]};
PLines[di]=PolyCurve.ByPoints(PPoints,true);
PExt[di]=PLines[di].ExtrudeAsSolid(Vector.ByCoordinates(0,0,1),25);
di=di+1;
}
CutMass=PExt[0].UnionAll(PExt);
CutSurface=Surface.ByPatch(PLines);
CutSurface=PolySurface.ByJoinedSurfaces(CutSurface);
return={CutMass,CutSurface};
}

//Bernhardinkatu
BernhardinkatuSlope=Vector.ByTwoPoints(Point.ByCoordinates(-609,113,12.8),Point.ByCoordinates(-486,120,(3.5+5.5)));
BernhardinkatuPoints={Point.ByCoordinates(-610,128,12.25),Point.ByCoordinates(-609,113,12.25),Point.ByCoordinates(-609,113,22.5),Point.ByCoordinates(-610,128,22.5)};
BernhardinkatuLine=PolyCurve.ByPoints(BernhardinkatuPoints,true);
BernhardinkatuMass=BernhardinkatuLine.ExtrudeAsSolid(BernhardinkatuSlope,250);

RampSlope=Vector.ByTwoPoints(Point.ByCoordinates(-609,113,18.25),Point.ByCoordinates(-486,120,10));
RampCutPoints={Point.ByCoordinates(-610,128,17.25),Point.ByCoordinates(-609,113,17.25),Point.ByCoordinates(-609,113,25),Point.ByCoordinates(-610,128,25)};
RampLine=PolyCurve.ByPoints(RampCutPoints,true);
RampCuttingMass=RampLine.ExtrudeAsSolid(RampSlope,250);

BuildingMass1=VolumetricMass.Difference(ParkSightLines[0]);
BuildingMass=BuildingMass1.Difference(BernhardinkatuMass);
BuildingMass=BuildingMass.Difference(RampCuttingMass);

//Entry/Exit Triangle
EnTriPnts={Point.ByCoordinates(-465.411644,222.985474,2.1),Point.ByCoordinates(-462.375319,233.504172,2.1),Point.ByCoordinates(-422.323500,171.657816,2.1),Point.ByCoordinates(-430.082047,156.780317,2.1)};
EntTriBou=PolyCurve.ByPoints(EnTriPnts,true);
EntTriSur=Surface.ByPatch(EntTriBou);
EntTriSol1=EntTriSur.Thicken(-15,false);
EntTriSol=EntTriSol1.Difference(ParkSightLines[0]);
BuildingMassEnt=BuildingMass.Union(EntTriSol);

//Extracting Top Surface
BuildingPolySurface=PolySurface.BySolid(BuildingMass);
BuildingSurfaces=BuildingPolySurface.Surfaces();
RampTopSurf=Flatten(BuildingSurfaces<1>.Intersect(RampCuttingMass));
RampTopSurf=RemoveIfNot(RampTopSurf,"Surface");
RampTopSurf=RampTopSurf[0];
//RampTopSurf=RampTopSurf.FlipNormalDirection();
TopSurf=BuildingSurfaces<1>.Intersect(ParkSightLines[0]);
TopSurf=Flatten(TopSurf);
TopSurf=RemoveIfNot(TopSurf,"Surface");
TopSurface=Flatten({TopSurf,RampTopSurf});

def remPnt(Li:var[])
{
LiF=RemoveIfNot(Li,"Line");
return=LiF;
}

//Function: Creating a Uniform Grid
def SurfaceGrid(surf,UnitDivision,Mass)
{
DivisionU=UnitDivision/(surf.PointAtParameter(0,0).DistanceTo(surf.PointAtParameter(1,0)));
DivisionV=UnitDivision/(surf.PointAtParameter(0,0).DistanceTo(surf.PointAtParameter(0,1)));
SurfPoints=Flatten(surf.PointAtParameter((0..1..~DivisionU)<1>,(0..1..~DivisionV)<2>));
SurfNormals=Flatten(surf.NormalAtParameter((0..1..~DivisionU)<1>,(0..1..~DivisionV)<2>));
SurfLines=Line.ByStartPointDirectionLength(SurfPoints,SurfNormals,20);
SurfInPoints=Flatten(SurfLines.DoesIntersect(surf));
SurfInLines=List.FilterByBoolMask(SurfLines,SurfInPoints)["in"];

//BuildingMass Intersects
Intersects=Flatten(Mass.Intersect(SurfInLines));
Intersects=remPnt(Intersects);

//Filter by Base Level
BaseLevelFilter1=Intersects.EndPoint.Z==2.1&&Intersects.EndPoint.Z<7.61?true:false;
BaseLevel1=Flatten(List.FilterByBoolMask(Intersects,BaseLevelFilter1)["in"]);
BaseLevelFilter2=Intersects.EndPoint.Z==7.6?true:false;
BaseLevel2=Flatten(List.FilterByBoolMask(Intersects,BaseLevelFilter2)["in"]);

//Returns BasePoint(2.1), RoofPoint(2.1),
return={BaseLevel1.EndPoint,BaseLevel1.StartPoint,BaseLevel2.EndPoint,BaseLevel2.StartPoint};
}

//Top and Bottom Grid (1-Base Lower Points,2-Top for Lower, 3-Base Upper, 4-Top for Upper

TopBottomGrid=SurfaceGrid(TopSurface,GridDensity,BuildingMass);

//Separate the Grids based on Levels
TopBottomGrid=List.Transpose(TopBottomGrid);
//LowerLevelFloorPoints
LLFP=TopBottomGrid[0];
//LowerLevelRoofPoints
LLRP=TopBottomGrid[1];
//UpperLevelFloorPoints
ULFP=TopBottomGrid[2];
//UpperLevelRoofPoints
ULRP=TopBottomGrid[3];

//Height Range1
h1={0,1.5,2.45,3.15,4.05,5.05,6.75,8.35,9.5,11.45,12.05,13.6,14.05,15.7,16.05,17.75,18};
//Height Range2
h2={1.45,2.4,3.1,4,5.00,6.7,8.15,9.5,11.45,12,13.55,14,15.65,16,17.75,18,20};

def HeightGroup(RoofPoints:var[],FloorPoints:var[],Height1,Height2)
{
R0=(RoofPoints.Z)>(Height1+2.1)&&(RoofPoints.Z)<(Height2+2.1)?true:false;
R0FilterIn=List.FilterByBoolMask(RoofPoints<1>,R0<2>)["in"];
F0FilterIn=List.FilterByBoolMask(FloorPoints<1>,R0<2>)["in"];
return={R0FilterIn,F0FilterIn};
}

//Lower Level Points Grouped by Height
LLPH=List.Transpose(HeightGroup(LLRP<1>,LLFP<1>,h1<2>,h2<2>)<2>);

//Upper Level Points Grouped by Height
ULPH=List.Transpose(HeightGroup(ULRP<1>,ULFP<1>,h1<2>,h2<2>)<2>);

//Function - Boundary Points in Cluster
def BoundaryPoints(PointsGrid:var[],GroupKey)
{
//Group Points with same X
GridX=GroupByKey(PointsGrid<1>,GroupKey)<2>;
GridMin=List.FirstItem(GridX<1>);
GridMax=List.LastItem(GridX<1>);

SingleItemFilter=GridMin==GridMax?true:false;
PeripheryMinX=List.FilterByBoolMask(GridMin<1>,SingleItemFilter<2>)["in"];

PeripheryMaxX=List.Reverse(List.FilterByBoolMask(GridMax<1>,SingleItemFilter<2>)["in"]);

PeripheryPoint=Flatten({PeripheryMinX,
PeripheryMaxX});
return=PeripheryPoint;
}

//Boundary Points
LLBPn=List.Transpose(BoundaryPoints(LLPH,GroupKeyX));
ULBPn=List.Transpose(BoundaryPoints(ULPH,GroupKeyX));

//Lower Level Boundary Curves
LLBP=Point.PruneDuplicates(LLBPn<1>,GridDensity+0.05);
LLBP[0][1][8]=List.RemoveItemAtIndex(LLBP[0][1][8],18);
LLBN=NurbsCurve.ByControlPoints(LLBP<1>,3,1);

//Lower Level Extrusions
LLBN=List.Transpose(LLBN);
LLBN=List.Transpose(LLBN<1>);
LLS=Solid.ByLoft(LLBN);
LLS=RemoveIfNot(Flatten(LLS),"Solid");

//Upper Level Boundary Curves
ULBP=Point.PruneDuplicates(ULBPn<1>,GridDensity+0.05);
ULBN=NurbsCurve.ByControlPoints(ULBP<1>,3,1);

//Upper Level Extrusions
ULBN=List.Transpose(ULBN);
ULBN=List.Transpose(ULBN<1>);
ULS=Solid.ByLoft(ULBN);
ULS=RemoveIfNot(Flatten(ULS),"Solid");

//InteriorBlocks=Solid.UnionAll(Flatten({LLS,ULS}));
InteriorBlocks=Flatten({LLS,ULS});
InteriorBlocks1=List.RemoveItemAtIndex(InteriorBlocks,{40,23,24});
ParkSightLines1=ParkSightLines[0].Translate(Vector.ByCoordinates(0,0,-1),0.1);
BuildingSkinMass=BuildingMass.Difference(ParkSightLines1);
BuildingSkinPunctured=BuildingMassEnt.Difference(InteriorBlocks1[0].UnionAll(InteriorBlocks1));

//Bridge
BrMsPts={Point.ByCoordinates(-471.821220,135.860936,2.1),Point.ByCoordinates(-470.797753,120.865169,2.1),Point.ByCoordinates(-533.930443,117.272251,2.1),Point.ByCoordinates(-544.177164,131.746015,2.1)};
BrMsBou=PolyCurve.ByPoints(BrMsPts);
BrMsSol1=BrMsBou.ExtrudeAsSolid(Vector.ByCoordinates(0,0,1),10);
BrMsSol=BrMsSol1.Difference(RampCuttingMass);
BrFlInt=BrMsSol.Intersect(RampCuttingMass);
BrFlInt=PolyCurve.ByJoinedCurves(BrFlInt);
BrFlInt=BrFlInt.Offset(0.5);
BrFlSur=Surface.ByPatch(BrFlInt);
BrFlSol1=BrFlSur.Thicken(1,false);
BrFlSol2=BrFlSur.Thicken(-5.5,false);
BrFlSol=BrFlSol1.Union(BrFlSol2);
BrFlSol=BrFlSol.Difference(ParkSightLines[0]);
BrFlSol=BrFlSol.Difference(RampCuttingMass);
BuildingSkinPunctured=BuildingSkinPunctured.Difference(BrFlSol);

//Volumetric Mass Bottom Surfaces
VMassSurfaces=PolySurface.BySolid(VolumetricMass);
VMassSurfaces=VMassSurfaces.Surfaces();
VMassBottomSurfaces=Flatten({VMassSurfaces[26],VMassSurfaces[17]});
VMassBottomSurface=PolySurface.ByJoinedSurfaces(VMassBottomSurfaces);

//Interior Blocks  Floor Area and Average Height
IntBlksBottomSurface=Flatten(InteriorBlocks.Intersect(VMassBottomSurface));
IntBlksBottomFlrArea=IntBlksBottomSurface.Area;
IntBlksBottomVol=InteriorBlocks.Volume;
IntBlksAvHeight=IntBlksBottomVol/IntBlksBottomFlrArea;

//Interior Blocks Surfaces
IntBlkSurfaces1=PolySurface.BySolid(InteriorBlocks);
IntBlkSurfaces1=IntBlkSurfaces1.Surfaces();
IntBlkSurfaces=List.Transpose(IntBlkSurfaces1);
IntBlkFlSurf=IntBlkSurfaces[0];
IntBlkRfSurf=IntBlkSurfaces[1];
IntBlkWlSurf=IntBlkSurfaces[2];

//Center of Plane Rotation
IntBlkBotCen=IntBlkFlSurf.PointAtParameter(0.5,0.5);
IntBlkU=(IntBlkFlSurf.PointAtParameter(0,0)).DistanceTo(IntBlkFlSurf.PointAtParameter(1,0));
IntBlkV=(IntBlkFlSurf.PointAtParameter(0,0)).DistanceTo(IntBlkFlSurf.PointAtParameter(0,1));
IntBlkCenShift=IntBlkU/2;
IntBlkBotCen=IntBlkBotCen.Translate(Vector.ByCoordinates(0,0,-1),IntBlkCenShift);
IntBlkCutPlane=Plane.ByOriginNormal(IntBlkBotCen,Vector.ByCoordinates(0,0,1));

DivAngle=Math.Round(IntBlkU/1.5);
RotAngle=0..180..#DivAngle;

def CutPlanes(Pl,ang:var[])
{
p=Pl<2>.Rotate(Pl.Origin<2>,Pl.YAxis<2>,ang<1>);
return=p;
}
IntBlkCutPlanes=CutPlanes(IntBlkCutPlane<1>,RotAngle<1>);
IntBlkCutPlanes=Flatten(IntBlkCutPlanes<1>);

//Center of Plane Rotation
IntBlkBotCen=IntBlkFlSurf.PointAtParameter(0.5,0.5);
IntBlkU=(IntBlkFlSurf.PointAtParameter(0,0)).DistanceTo(IntBlkFlSurf.PointAtParameter(1,0));
IntBlkV=(IntBlkFlSurf.PointAtParameter(0,0)).DistanceTo(IntBlkFlSurf.PointAtParameter(0,1));
IntBlkCenShift=IntBlkU/2;
IntBlkBotCen=IntBlkBotCen.Translate(Vector.ByCoordinates(0,0,-1),IntBlkCenShift);
IntBlkCutPlane=Plane.ByOriginNormal(IntBlkBotCen,Vector.ByCoordinates(0,0,1));

DivAngle=Math.Round(IntBlkU/1.5);
RotAngle=0..180..#DivAngle;

def CutPlanes(Pl,ang:var[])
{
p=Pl<2>.Rotate(Pl.Origin<2>,Pl.YAxis<2>,ang<1>);
return=p;
}
IntBlkCutPlanes=CutPlanes(IntBlkCutPlane<1>,RotAngle<1>);
IntBlkCutPlanes=Flatten(IntBlkCutPlanes<1>);


//Function - Create Interior Block Components
def IntBlComponents(IntBlks,IntsPlns:var[])
{
IntBlkDivs=Flatten(IntBlks<1>.Intersect(IntsPlns<2>));

//Filter out Small Surfaces
IntBlkDivsAr=IntBlkDivs.Area;
IntBlkDivsPr=IntBlkDivs.Perimeter;
IntBlkPerArRat=IntBlkDivsPr/IntBlkDivsAr;

IntBlkDivFil=IntBlkPerArRat>3?true:false;
IntBlkDivf=List.FilterByBoolMask(IntBlkDivs<0>,IntBlkDivFil<0>)["out"];
IntBlkFrmCl1=IntBlkDivf.PerimeterCurves();
IntBlkFrmCl=PolyCurve.ByJoinedCurves(IntBlkFrmCl1);

//Interior Blocks Frame
IntBlkSurfaces0=PolySurface.BySolid(IntBlks);
IntBlkSurfaces1=IntBlkSurfaces0.Surfaces();
IntBlkSurfaces=List.Transpose(IntBlkSurfaces1);
IntBlkFlSurf=IntBlkSurfaces[0];
IntBlkRfSurf=IntBlkSurfaces[1];
IntBlkWlSurf=IntBlkSurfaces[2];
IntBlkBotCen=IntBlkFlSurf.PointAtParameter(0.5,0.5);
IntBlkV=(IntBlkFlSurf.PointAtParameter(0,0)).DistanceTo(IntBlkFlSurf.PointAtParameter(0,1));

//GluLam Span to Depth ratio is 21;
IntBlkFrmDep=((IntBlkV/21)/2)<0.6?0.6:((IntBlkV/21)/3);
IntBlkFrmThk=IntBlkFrmDep<=0.6?0.25:0.45;
IntBlkFrmOuterEdges=IntBlkFrmCl.Offset(IntBlkFrmDep,0);
IntBlkFrmInnerEdges=IntBlkFrmCl.Offset(-1*IntBlkFrmDep,0);
IntBlkFrmOuterPatch0=Surface.ByPatch(IntBlkFrmOuterEdges);
IntBlkFrmOuterPatchFil=IntBlkFrmOuterPatch0==Surface?false:true;
IntBlkFrmOuterPatch=RemoveIfNot(IntBlkFrmOuterPatch0,"Surface");
IntBlkFrmOuterSol=IntBlkFrmOuterPatch.Thicken(IntBlkFrmThk,true);
IntBlkFrmInnerEdges=List.FilterByBoolMask(IntBlkFrmInnerEdges,IntBlkFrmOuterPatchFil)["in"];
IntBlkFrmInnerPatch=Surface.ByPatch(IntBlkFrmInnerEdges);
IntBlkFrmInnerSol=IntBlkFrmInnerPatch.Thicken(IntBlkFrmThk,true);
IntBlkFrmSol1=IntBlkFrmOuterSol.Difference(IntBlkFrmInnerSol);
IntBlkFrmSol2=IntBlkFrmInnerSol.Difference(IntBlkFrmOuterSol);
IntBlkFrmSol3=IntBlkFrmSol1.Union(IntBlkFrmSol2);
IntBlkFrmSol4=RemoveIfNot(IntBlkFrmSol3,"Solid");
IntBlkFrmSol=List.Count(IntBlkFrmSol4)>0?IntBlkFrmSol4[0].UnionAll(IntBlkFrmSol4):IntBlkFrmSol4;

//Interior Blocks Walls;
IntBlkWlThk=0.1;
IntBlkWlSol1=IntBlkWlSurf.Thicken(IntBlkWlThk,1);
IntBlkWlSol=IntBlkWlSol1.Difference(IntBlkFrmSol);

//Interior Block Floors
IntBlkFlOfp=1*((IntBlkFrmDep)+0.2);
IntBlkFlOfn=-1*((IntBlkFrmDep)+0.2);
//IntBlkFlTk=((IntBlkFrmDep)+0.5);
IntBlkFlTk=0.15;
FlBoun1=IntBlkFlSurf.PerimeterCurves();
FlBoun1per=FlBoun1.Length;
FlBounP=FlBoun1.Offset(IntBlkFlOfp);
FlBounPper=FlBounP.Length;
FlBounN=FlBoun1.Offset(IntBlkFlOfn);
FlBounNper=FlBounN.Length;
FlBoun2=FlBounPper>FlBoun1per?FlBounP:FlBounN;
FlBoun3=FlBoun2.DivideEqually(10);
FlBoun=PolyCurve.ByJoinedCurves(FlBoun3);
IntBlkFlSurfa=Surface.ByPatch(FlBoun);
IntBlkFlSol=IntBlkFlSurfa.Thicken(IntBlkFlTk,true);

//Interior Block Roofs
SkLtWd=0.5;
IntBlkRfOfp=1*((IntBlkWlThk/2)+SkLtWd);
IntBlkRfOfn=-1*((IntBlkWlThk/2)+SkLtWd);
IntBlkRfTk=((IntBlkFrmDep*2)+0.3);
RfBoun1=IntBlkRfSurf.PerimeterCurves();
RfBoun1per=RfBoun1.Length;
RfBounP=RfBoun1.Offset(IntBlkRfOfp);
RfBounPper=RfBounP.Length;
RfBounN=RfBoun1.Offset(IntBlkRfOfn);
RfBounNper=RfBounN.Length;
RfBoun2=RfBounPper<RfBoun1per?RfBounP:RfBounN;
//RfBoun3=RfBoun2.DivideEqually(10);
//RfBoun=PolyCurve.ByJoinedCurves(RfBoun3);
IntBlkRfSurfa=Surface.ByPatch(RfBoun2);
IntBlkRfSol=IntBlkRfSurfa.Thicken(IntBlkRfTk,true);

//Interior Block Sky Lights
IntBlkSkOf=0.15;
IntBlkSkOfp=1*(IntBlkSkOf);
IntBlkSkOfn=-1*(IntBlkSkOf);
IntBlkSkTk=0.15;
SkBounP=RfBoun1.Offset(IntBlkSkOfp);
SkBounPper=SkBounP.Length;
SkBounN=RfBoun1.Offset(IntBlkSkOfn);
SkBounNper=SkBounN.Length;
SkBounN=RfBoun1.Offset(IntBlkSkOfn);
SkBounNper=SkBounN.Length;
SkBoun=SkBounPper>RfBoun1per?SkBounP:SkBounN;
IntBlkSkSurfa=Surface.ByPatch(SkBoun);
IntBlkSkSol1=IntBlkSkSurfa.Thicken(IntBlkSkTk,true);
IntBlkSkSol2=IntBlkSkSol1.Difference(IntBlkRfSol);
IntBlkSkSol=IntBlkSkSol2.Difference(IntBlkFrmSol);

return={IntBlkFrmSol,IntBlkWlSol,IntBlkFlSol,IntBlkRfSol,IntBlkSkSol};

}

IntBlkComponents=IntBlComponents(InteriorBlocks,IntBlkCutPlanes);
IntBlkComponentsT=List.Transpose(IntBlkComponents);

//Interior Block Frames
IntBlkFrs=IntBlkComponentsT[0];
IntBlkFrs=RemoveIfNot(IntBlkFrs,"Solid");
IntBlkFrs=IntBlkFrs[0].UnionAll(IntBlkFrs);

//Interior Block Walls
IntBlkWls=IntBlkComponentsT[1];
IntBlkWls=RemoveIfNot(IntBlkWls,"Solid");
IntBlkWls=IntBlkWls[0].UnionAll(IntBlkWls);

//Interior Block Floors
IntBlkFls=IntBlkComponentsT[2];
IntBlkFls=Flatten(IntBlkFls);
IntBlkFls=RemoveIfNot(IntBlkFls,"Solid");
IntBlkFls=IntBlkFls[0].UnionAll(IntBlkFls);

//Interior Block Roofs
IntBlkRfs=IntBlkComponentsT[3];
IntBlkRfs=Flatten(IntBlkRfs);
IntBlkRfs=RemoveIfNot(IntBlkRfs,"Solid");
IntBlkRfs=IntBlkRfs[0].UnionAll(IntBlkRfs);

//Interior Block SkyLights
IntBlkSks=IntBlkComponentsT[4];
IntBlkSks=Flatten(IntBlkSks);
IntBlkSks=RemoveIfNot(IntBlkSks,"Solid");
IntBlkSks=IntBlkSks[0].UnionAll(IntBlkSks);

//Building Mass Punctured
BuildingSkinPunctured=BuildingSkinPunctured.Difference(IntBlkFrs);

//Interior Block Roof Covering;
IntBlkRfs1=IntBlkComponentsT[3];
IntBlkRfs1=Flatten(IntBlkRfs1);
IntBlkRfs1=RemoveIfNot(IntBlkRfs1,"Solid");

def Roofing(RoofSol)
{
RThkn=0.05;
RoofPol=PolySurface.BySolid(RoofSol);
RoofSur=RoofPol.Surfaces();
RoofTop=RoofSur[0];
RoofTopCen=RoofSur[0].PointAtParameter(0.5,0.5);
RoofTopSc=RoofSur[0].PointAtParameter(0.5,1);
RoofTopSc1=RoofSur[0].PointAtParameter(0.5,1.025);
RTConcen1=RoofTop.Scale(RoofTopCen,RoofTopSc,RoofTopSc1);
RTConcen1=RTConcen1.Thicken(RThkn*1);
RoofTopSc2=RoofSur[0].PointAtParameter(0.5,0.9);
RTConcen2=RoofTop.Scale(RoofTopCen,RoofTopSc,RoofTopSc2);
RTConcen2=RTConcen2.Thicken(RThkn*2);
RoofTopSc3=RoofSur[0].PointAtParameter(0.5,0.8);
RTConcen3=RoofTop.Scale(RoofTopCen,RoofTopSc,RoofTopSc3);
RTConcen3=RTConcen3.Thicken(RThkn*3);
RoofTopSc4=RoofSur[0].PointAtParameter(0.5,0.7);
RTConcen4=RoofTop.Scale(RoofTopCen,RoofTopSc,RoofTopSc4);
RTConcen4=RTConcen4.Thicken(RThkn*4);
RoofTopSc5=RoofSur[0].PointAtParameter(0.5,0.6);
RTConcen5=RoofTop.Scale(RoofTopCen,RoofTopSc,RoofTopSc5);
RTConcen5=RTConcen5.Thicken(RThkn*5);
RTConcen={RTConcen1,RTConcen2,RTConcen3,RTConcen4,RTConcen5};
RTpRfng=RTConcen[0].UnionAll(RTConcen);
return=RTpRfng;
}
IntBlkRfCvs=Roofing(IntBlkRfs1);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQh-G7iqLWYB4hedfT%2F-LfQh8Iff-auQXqZoJEt%2FGH-8318189361-1.jpg?alt=media\&token=dec87725-a4df-4df9-86c7-da4601f085df)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQh-G7iqLWYB4hedfT%2F-LfQhJzirggskyF5zhsr%2FGH-8318189361-2.jpg?alt=media\&token=5cd17700-cc82-4f4e-abd9-edeba1e26175)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQh-G7iqLWYB4hedfT%2F-LfQhHUepB-bSJuwb49b%2FGH-8318189361-3.jpg?alt=media\&token=63c8eee9-fdb3-444a-9c34-0e2255464953)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQh-G7iqLWYB4hedfT%2F-LfQhFaT7eP11iGGwKk1%2FGH-8318189361-4.jpg?alt=media\&token=839fd583-7a61-4d8a-88a4-5d807032c8d5)


# National War Museum

Design Competition Entry

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQfpR9j9hDcR1dLQuI%2FNWM-10.jpg?alt=media\&token=62b0ff35-fb60-4e9a-ab9b-cae5b19e0b38)

```d
//Ashoka Chakra
chkC1=Circle.ByCenterPointRadius(Point.Origin(),190);

chkPc1=PolyCurve.ByPoints(Point.PruneDuplicates(Flatten(Point.ByCoordinates
({-4.3182,-2.9278,-1.6079,-5.552,0,5.552,1.6079,2.9278,4.3182},
{32.8,32.8903,33.4260,65.2,157.6,65.2,33.4260,32.8903,32.8})<1>.
Rotate(Point.Origin(),Vector.ZAxis(),(360..0..#25)<2>)),0.001),true);

chkA1=Arc.ByThreePoints(Point.ByCoordinates(-8.5,166.5),Point.ByCoordinates(0,158),
Point.ByCoordinates(8.5,166.5));
chkA2=List.DropItems(chkA1.Rotate(Point.Origin(),Vector.ZAxis(),360..0..#25),1).
Rotate(Point.Origin(),Vector.ZAxis(),7.5);
chkL2=Line.ByStartPointEndPoint(List.ShiftIndices(chkA2.StartPoint,-1),chkA2.EndPoint);
chkPc2=PolyCurve.ByJoinedCurves(Flatten(Transpose({chkA2,chkL2})));

chkSld1=chkPc1.ExtrudeAsSolid(Vector.ZAxis(),1).Union(chkC1.ExtrudeAsSolid
(Vector.ZAxis(),1).Difference(chkPc2.ExtrudeAsSolid(Vector.ZAxis(),1)));
chkSrf1=chkSld1.Intersect(Plane.XY());

//Data file
fil1=File.FromPath("..\DataExtraction\\boundaries.xls");

//Boundary
exl4=Excel.ReadFromFile(fil1,("Boundary"+(1..2))<1>,true);
exl5=List.DropItems(List.Transpose(exl4<1>)<1><2>,1);
exl6=Math.Round(String.ToNumber(exl5),3);
minXDed=718180;
minYDed=3167444;
enx2=List.GetItemAtIndex(exl6<1>,0)-minXDed;
eny2=List.GetItemAtIndex(exl6<1>,1)-minYDed;
stx2=List.GetItemAtIndex(exl6<1>,3)-minXDed;
sty2=List.GetItemAtIndex(exl6<1>,4)-minYDed;
ep2=Point.ByCoordinates(enx2,eny2);
sp2=Point.ByCoordinates(stx2,sty2);
bdpn1=List.SortByKey(sp2[0],{0,1,11,9,10,2,8,6,7,5,4,3});
bdry1=Polygon.ByPoints(bdpn1["sorted list"]);
bdpn2=List.SortByKey(sp2[1],{0,1,6,5,4,3,2});
bdry2=Polygon.ByPoints(bdpn2["sorted list"]);
bdry3=Polygon.ByPoints(Flatten({bdpn1["sorted list"][9..10],bdpn2["sorted list"][{1,0,6}]}));
bdry4=PolySurface.ByJoinedSurfaces({bdry1.Patch(),bdry3.Patch(),bdry2.Patch()}).PerimeterCurves();

//Trees
exl7=String.ToNumber(Transpose(Excel.ReadFromFile(fil1,("trees"),true)));
trpt1=List.FirstItem(List.SortByKey(Point.ByCoordinates(exl7[0]-minXDed,exl7[1]-minYDed,0),exl7[3]));
trbl1=bdry1.ContainmentTest(trpt1)||bdry2.ContainmentTest(trpt1);
trpt2=List.FilterByBoolMask(trpt1,trbl1)["in"];
trsl1=(Circle.ByCenterPointRadius(trpt2,0.5)).ExtrudeAsSolid(Vector.ZAxis(),0.5);

//Existing Buildings
exl1=Excel.ReadFromFile(fil1, ("Building"+(1..18))<1>,true);
exl2=List.DropItems(List.Transpose(exl1<1>)<1><2>,1);
exl3=Math.Round(String.ToNumber(exl2),3);
enx1=List.GetItemAtIndex(exl3<1>,0)-minXDed;
eny1=List.GetItemAtIndex(exl3<1>,1)-minYDed;
stx1=List.GetItemAtIndex(exl3<1>,3)-minXDed;
sty1=List.GetItemAtIndex(exl3<1>,4)-minYDed;
ep1=Point.ByCoordinates(enx1,eny1);
sp1=Point.ByCoordinates(stx1,sty1);
Line.ByStartPointEndPoint(sp1,ep1);

//Building 0
bg1dr1=Vector.ByTwoPoints(sp1[0][2],sp1[0][1]);
bg1pt1=sp1[0][1].Translate(bg1dr1,9);
bg1pt2=sp1[0][28].Translate(bg1dr1,2);
bg1pt3=sp1[0][19].Translate(bg1dr1,1);
bg1pt4=bg1pt3.Translate(18,-30,0);
bg1pt5=bg1pt4.Translate(0,0,12);

//Amphiteater
ampcir1=Circle.ByCenterPointRadius(bg1pt4,20).ExtrudeAsSolid(Vector.ZAxis(),-4);
ampcir2=Circle.ByCenterPointRadius(bg1pt4.Translate(Vector.ZAxis(),-4),12).ExtrudeAsSolid(Vector.ZAxis(),-1);
site1=PolyCurve.ByJoinedCurves(bdry4).ExtrudeAsSolid(Vector.ZAxis(),-8);
site2=(site1.Difference(ampcir1)).Difference(ampcir2);

//Corridor
crdDir1=Vector.ByTwoPoints(sp1[1][3],sp1[2][2]);
crdDir2=Vector.ByTwoPoints(sp1[14][0],sp1[1][3]);
crdPnt1=sp1[14][0].Translate(crdDir1,3).Translate(crdDir2,-45);
crdPln1=Plane.ByOriginNormal(crdPnt1,crdDir2);
crdSld1=Rectangle.ByWidthLength(crdPln1,9,6).Translate(0,0,4.5).ExtrudeAsSolid(crdDir2,290);
crdPnt2=crdPnt1.Translate(crdDir2,290).Translate(0,0,-2);

//Tunnel 1
tn1Dir1=Vector.ByTwoPoints(crdPnt2,bg1pt4.Translate(0,0,-2.25));
tn1Pln1=Plane.ByOriginNormal(crdPnt2,tn1Dir1);
tn1Sld1=Rectangle.ByWidthLength(tn1Pln1,3.5,6).ExtrudeAsSolid(tn1Dir1);
tn1Sld2=tn1Sld1.Difference(ampcir1);

//Tunnel 2
tn2Dir1=Vector.ByTwoPoints(bg1pt4.Translate(0,0,-2.25),sp2[0][1].Translate(0,0,-2.25));
tn2Pln1=Plane.ByOriginNormal(bg1pt4.Translate(0,0,-2),tn2Dir1);
tn2Sld1=Rectangle.ByWidthLength(tn2Pln1,3.5,6).ExtrudeAsSolid(tn2Dir1);
tn2Sld2=tn2Sld1.Difference(ampcir1);

//Vertical Transition
vt1Sld1=Circle.ByCenterPointRadius(crdPnt2.Translate(0,0,-2),8).ExtrudeAsSolid(Vector.ZAxis(),14);

crdSld2=Solid.ByUnion({crdSld1,tn1Sld2,vt1Sld1,tn2Sld2});
crdSld3=Solid.ByUnion({crdSld1,vt1Sld1});
site3=site2.Difference(crdSld2);
site4=site3.Explode()[10];
site5=site3.Explode()[0..9];
site6=site3.Explode()[12..15];

//Main Chakra
chkSrf2=chkSrf1.Scale(0.1).Translate(bg1pt4.X,bg1pt4.Y,11).Thicken(0.5);
chkSrf2A=chkSrf1.Scale(0.1).Translate(bg1pt4.X,bg1pt4.Y,11);

bg1dr2=Vector.ByTwoPoints(bg1pt1,bg1pt4);
bg1dr3=Vector.ByTwoPoints(bg1pt3,bg1pt4);
bg1dr4=Vector.ByTwoPoints(bg1pt2,bg1pt4);

bg1dr10=Vector.ByTwoPoints(sp1[0][10],sp1[0][15]);
bg1pt10=sp1[0][10].Translate(bg1dr10,-50);
bg1pt11=sp1[0][15].Translate(bg1dr10,20);

bg1dr11=Vector.ByTwoPoints(bg1pt4,bg1pt10);
bg1dr12=Vector.ByTwoPoints(bg1pt4,bg1pt11);

bg1pt12=(bg1pt10.Translate(0,0,18));
bg1pt13=(bg1pt10.Translate(0,0,21)).Translate(bg1dr11,3);
bg1pt14=(bg1pt11.Translate(0,0,18));
bg1pt15=(bg1pt11.Translate(0,0,21)).Translate(bg1dr12,3);

bg1ar10=Arc.ByThreePoints(bg1pt10,bg1pt12,bg1pt13);
bg1ar11=Arc.ByThreePoints(bg1pt11,bg1pt14,bg1pt15);
bg1sr10=Surface.ByLoft({bg1ar10,bg1ar11});

bg1ar1=Arc.ByThreePoints(bg1pt1,bg1pt3,bg1pt2);
bg1cr1=Circle.ByCenterPointRadius(bg1pt4,20);

bg1ar2=NurbsCurve.ByControlPoints({bg1pt1,(bg1pt1.Translate(0,0,15)).Translate(bg1dr2,4),(bg1pt1.Translate(0,0,45)).Translate(bg1dr2,25),bg1pt5},3);
bg1ar3=NurbsCurve.ByControlPoints({bg1pt3,(bg1pt3.Translate(0,0,18)).Translate(bg1dr3,0),(bg1pt3.Translate(0,0,45)).Translate(bg1dr3,21),bg1pt5},3);
bg1ar4=NurbsCurve.ByControlPoints({bg1pt2,(bg1pt2.Translate(0,0,15)).Translate(bg1dr4,3),(bg1pt2.Translate(0,0,45)).Translate(bg1dr4,21),bg1pt5},3);
bg1sr1=Surface.ByLoft({bg1ar2,bg1ar3,bg1ar4});

bg1cr1=PolyCurve.ByPoints({bg1pt4,bg1pt10.Translate(bg1dr10,12),bg1pt11.Translate(bg1dr10,-10)},true).Translate(Vector.ZAxis(),3);
bg1sl1=bg1cr1.ExtrudeAsSolid(Vector.ZAxis(),15).Difference(Circle.ByCenterPointRadius(bg1pt4,10).ExtrudeAsSolid(Vector.ZAxis(),25));
bg1sl2=(bg1sl1.Trim(bg1sr1,bg1pt4)).Trim(bg1sr10,bg1pt10);
bg1sr2=Flatten(bg1sl2.Explode())[{1,2,4}];

bg1sr11={bg1sr1,bg1sr10}.ToNurbsSurface();
bg1sr12=TSplineSurface.ByNurbsSurfaceUniform(bg1sr11,8,8,true,true,true);
bg1sr13=TSplineSurface.Thicken(bg1sr12,1,true);
bg1sr14=bg1sr12[0].WeldCoincidentVertices(0.001);

bg1msh1=bg1sr13.ToMesh(1,0.01);

bldg0=Flatten({bg1sr13,bg1sr13,bg1sl2});

//Function - Building Footprint
def bldBdr (sp1:var[]..[],ep1:var[]..[],bn,sq:var[]..[])
{
blps=List.SortByKey(sp1[bn],sq)["sorted list"];
blpe=List.SortByKey(ep1[bn],sq)["sorted list"];
blpn=Equals(blps<1>,List.ShiftIndices(blps,1)<1>)?blpe:blps;
bldg=PolyCurve.ByPoints(SetUnion(blpn,blpe),true);
return=bldg;
};

//Existing Building Footprint
bldg1=bldBdr(sp1,ep1,1,{0,1,3,2});
bldg2=bldBdr(sp1,ep1,2,{2,0,3,1});
bldg3=bldBdr(sp1,ep1,3,{0,2,1,3});
bldg4=bldBdr(sp1,ep1,4,{2,3,1,0});
bldg5=bldBdr(sp1,ep1,5,{3,0,1,2});
bldg6=bldBdr(sp1,ep1,6,{2,3,1,0});
bldg7=bldBdr(sp1,ep1,7,{1,2,3,0});
bldg8=bldBdr(sp1,ep1,8,{1,0,2,3});
bldg9=bldBdr(sp1,ep1,9,{2,0,3,1});
bldg10=bldBdr(sp1,ep1,10,{3,0,2,1});
bldg11=bldBdr(sp1,ep1,11,{1,0,2,3});
bldg12=bldBdr(sp1,ep1,12,{2,0,1,3});
bldg13=bldBdr(sp1,ep1,13,{2,3,1,0});
bldg14=bldBdr(sp1,ep1,14,{0,3,2,1});
bldg15=bldBdr(sp1,ep1,15,{2,3,1,0});
bldg16=bldBdr(sp1,ep1,16,{2,3,1,0});
bldg17=bldBdr(sp1,ep1,17,{2,3,1,0});

bldgs={bldg1,bldg2,bldg3,bldg4,bldg5,bldg6,bldg7,bldg8,bldg9,bldg10,bldg11,
bldg12,bldg13,bldg14,bldg15,bldg16,bldg17}.ExtrudeAsSolid(Vector.ZAxis(),12);

//Chakras on buildings
bldgs1=bldgs[{0,2,4,6,8,9,10,11,12,13,14,16}].Explode();
bld1Sr1=List.GetItemAtIndex(bldgs1<1>,{2,0,1,2,1,2,0,1,0,1,0,0}<1>);
bld1Cs1=bld1Sr1.CoordinateSystemAtParameter(0.5,0.5);
chkSrf3=((chkSrf1.Scale(0.02))<1>.Transform(bld1Cs1<2>)).Thicken(0.25);

//Dome
dmci1=Circle.ByCenterPointRadius(Point.ByCoordinates(0,0,2),3);
dmci2=Circle.ByCenterPointRadius(Point.ByCoordinates(0,0,2.25),2.75);
dmci3=Circle.ByCenterPointRadius(Point.ByCoordinates(0,0,2.25),2.5);
dmci4=Circle.ByCenterPointRadius(Point.ByCoordinates(0,0,2.75),2.25);
dmci5=Circle.ByCenterPointRadius(Point.ByCoordinates(0,0,3.65),1.75);
dmci6=Circle.ByCenterPointRadius(Point.ByCoordinates(0,0,4),0.5);
dmrc1=Rectangle.ByWidthLength(5.5432772,5.5432772).ExtrudeAsSolid(Vector.ZAxis(),1.5);
dmoc1=Polygon.RegularPolygon(dmci1,8).ExtrudeAsSolid(Vector.ZAxis(),-0.5).Rotate(Point.Origin(),Vector.ZAxis(),22.5);
dmoc2=Solid.ByLoft({Polygon.RegularPolygon(dmci1,8),Polygon.RegularPolygon(dmci2,8)}).Rotate(Point.Origin(),Vector.ZAxis(),22.5);
dmhm1=Solid.ByLoft({dmci3,dmci4,dmci5,dmci6});
dome1=Solid.ByUnion({dmrc1,dmoc1,dmoc2,dmhm1});

bld1Sr2=List.GetItemAtIndex((bldgs.Explode())<1>,({2,1,0,0,1,0,2,0,1,2,0,1,0,1,0,2,0})<1>);
bld1Sr3=List.GetItemAtIndex((bldgs.Explode())<1>,({0,3,2,2,3,3,0,2,3,0,2,3,2,3,2,0,2})<1>);
bld1Pt1=bld1Sr2.PointAtParameter(0.5,1);
bld1Pt2=bld1Sr3.PointAtParameter(0.5,1);
bld1Pt3=bld1Sr2.PointAtParameter(1,1);
bld1Dr1=Vector.ByTwoPoints(bld1Pt1,bld1Pt2);
bld1Dr2=Vector.ByTwoPoints(bld1Pt2,bld1Pt3);
//bld1Pt4=bld1Pt1<1>.Translate(bld1Dr1<1>,(6..#14..10)<2>);
bld1Pt4=bld1Pt1<1>.Translate(bld1Dr1<2>,(6..#14..10)<2>);
bld1Bl1=bld1Pt4.DoesIntersect(bldgs);
bld1Pt5=List.FilterByBoolMask(bld1Pt4,bld1Bl1)["in"];
bld1cs5=CoordinateSystem.ByOriginVectors(bld1Pt5<1>,bld1Dr2,bld1Dr1,Vector.ZAxis());

dome11=Solid.ByUnion(Flatten(dmrc1.Transform(bld1cs5)));
dome12=Solid.ByUnion(Flatten(Solid.ByUnion({dmoc1,dmoc2}).Transform(bld1cs5)));
dome13=Solid.ByUnion(Flatten(dmhm1.Transform(bld1cs5)));
domes={dome11,dome12,dome13};

//Direct Shape
dsCat1=Category.ByName("Generic Models");
dsSit1=DirectShape.ByGeometry(site4,dsCat1,Material.ByName(".site1"),"nwmSite");
dsTre1=DirectShape.ByGeometry(trsl1,dsCat1,Material.ByName(".trees1"),"nwmTrees");
dsTun1=DirectShape.ByGeometry(site5,dsCat1,Material.ByName(".tunnel1"),"nwmTunnel");
dsCrt1=DirectShape.ByGeometry(site6,dsCat1,Material.ByName(".court1"),"nwmCourt");
dsCrd1=DirectShape.ByGeometry(crdSld3,dsCat1,Material.ByName(".corridor1"),"nwmCorridor");
dsBl01=DirectShape.ByMesh(bg1msh1[0],dsCat1,Material.ByName(".building01"),"nwmFeature01");
dsBl02=DirectShape.ByMesh(bg1msh1[1],dsCat1,Material.ByName(".building02"),"nwmFeature02");
dsBl03=DirectShape.ByGeometry(bg1sl2,dsCat1,Material.ByName(".building03"),"nwmGarage");
dsBl11=DirectShape.ByGeometry(bldgs,dsCat1,Material.ByName(".building11"),"nwmBuildings");
dsDom1=DirectShape.ByGeometry(dome11,dsCat1,Material.ByName(".domes1"),"nwmDomes01");
dsDom2=DirectShape.ByGeometry(dome12,dsCat1,Material.ByName(".domes2"),"nwmDomes02");
dsDom3=DirectShape.ByGeometry(dome13,dsCat1,Material.ByName(".domes3"),"nwmDomes03");
dsChk1=DirectShape.ByGeometry(chkSrf2,dsCat1,Material.ByName(".chakra1"),"nwmChakra01");
dsChk2=DirectShape.ByGeometry(chkSrf3,dsCat1,Material.ByName(".chakra2"),"nwmChakra02");
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQgNnklvmN-s_cdw9x%2FNWM-01.jpg?alt=media\&token=82c745b8-1c5a-4a3f-b223-3facd5f60669)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQgLeRwq0Gcomvt40m%2FNWM-02.jpg?alt=media\&token=3f66985a-c13d-4fe5-a83f-a6f67d63c577)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQgJUajCSH7ibjQn4A%2FNWM-03.jpg?alt=media\&token=1b502f67-bd78-422f-882a-365acaae9ac6)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQgHWn11G02LFc9ykr%2FNWM-04.jpg?alt=media\&token=188c223e-5a3a-4ac5-a73e-c4d6ccff7950)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQgEQDyjQEG9vL0L1X%2FNWM-05.jpg?alt=media\&token=e5cc1aec-6b7d-47ec-b213-072aa56d09d9)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQgC6qc5A-D_iyejLa%2FNWM-06.jpg?alt=media\&token=75e73718-35d3-415b-bd88-9765d1716e4c)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQg9RvN_4zECvFp3RL%2FNWM-07.jpg?alt=media\&token=2e5f7fba-7775-46f3-a76a-4b1db796a881)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQg6WvwjPY4rEFxMIQ%2FNWM-08.jpg?alt=media\&token=68d35ec3-1739-41d7-a4cf-eeaa9951fd72)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQeKwqLFEF5UCWwfz2%2F-LfQg2pbekdP7FY4om4A%2FNWM-09.jpg?alt=media\&token=3563d91f-a426-4b4c-8310-9c74f6ede058)


# National War Memorial

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zdcemcEMX4zzeMlC%2FPage0.jpg?alt=media\&token=a940e1c1-9921-4c23-8f5e-72f6d66b1241)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zgGh5e9ElrPIpNV7%2FPage1.jpg?alt=media\&token=da026c43-2cc6-4bb4-9ba4-568397699bdf)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zjKKTxx-6Uonlg2i%2FPage2.jpg?alt=media\&token=9e804528-86ba-4b7f-97db-b90cb0b0d7cb)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zlmkQVGcIJl08vcH%2FPage3.jpg?alt=media\&token=fbb03004-45f2-4b8e-954b-a263932bafc0)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zng7fvHa-m-Rx5s_%2FPage4.jpg?alt=media\&token=ae51ce99-caae-41dd-a057-3ad1c4de4f82)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8r6fnF4YYbIgezX9D%2F-Lh8vSvee9st-0P1isp1%2FNationalWarMemorial.jpg?alt=media\&token=512762b4-2361-4302-89d4-f56249de50be)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zqDIR6dsAgYHzg0y%2FPage6.jpg?alt=media\&token=11af9dca-a293-472d-8a95-775642cbf8f6)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zsJRSBD_9kJuj0_4%2FPage7.jpg?alt=media\&token=b8dcc130-c6bf-4dc3-a74d-0aa5589f0faa)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zuM9Qjo2SNIxOtJ4%2FPage8.jpg?alt=media\&token=b3a07941-17e6-481d-9f2c-749f92f8a4c9)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh8zx-U2o6QBFPI9J6O%2FPage9.jpg?alt=media\&token=3140499f-63cf-44f5-bded-acc188e1923a)


# Indflorescence

Steel Sculpture Competition

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MkjnuLnW9OdmEBk6d6r%2F-MkjrMPUZ2XPv5TsaQiu%2Findflorescence-1.png?alt=media\&token=5beb153c-1ed1-484a-a750-dbcce4ce9397)

Q: What do you see?

A: Flower, Windmill, Diamond, Trophy

Q: Can you spot the depiction of India?

A: Colors, Chakra, Lotus

Hint: Nothing abstract or intellectual.

Hint: Ignore the reflection.&#x20;

Hint: Focus on the lower ‘petals’.

A: Really! How did I not see it earlier?

India ( geographical name | In·​dia | in-dē-ə )

: large peninsular region that is usually referred to as a subcontinent and is located in southern Asia south of the Himalayas between the Bay of Bengal and the Arabian Sea<br>

Whether on a map or from outer space, the peninsular profile of the sub continent is something every Indian would identify with and relate to.

Inflorescence (noun | in·​flo·​res·​cence | in-flə-ˈre-sᵊn(t)s)&#x20;

: the budding and unfolding of blossoms<br>

The flower is immediately perceived by everybody, but the obvious relevance to India (and only India) is hidden in plain sight. While the India connection can be seen by even a child, to see, would require the presence of some India within. And once seen, it is difficult to unsee.<br>

{% embed url="<https://www.notionsofindia.com/>" %}

**Amorphous and Decipherable**&#x20;

![](https://lh5.googleusercontent.com/V4gRdad4EY8zPeV7qed4K_VMmA5g8tcOkG1CIonQf8uLzKNqMPwIW4-NFIyRYrRne42QrtAzB9NsbQxNioVlmpqv-8doxRGMwnLmCpE5oMFu9DRfkupk3Q2ZlJS4kvxaoyyANnNV=s0)

India, to a child aware of the idea of a nation, will be very different from an adult’s perception of India. A foreigner’s perception of any aspect of India might be far removed from the reality of that aspect of India.   Even the reality of India here and now can be quite different some distance and time away. In general, it is difficult to generalize the idea of India. However, in the pursuit of something that would unquestionably convey an essence of India the attempt is to find a common something that anybody would unambiguously identify with India. Something that is more than what it appears to be. Something that will be as relevant tomorrow as it is today.  Something that you can see only when you carry some of it within you. Something that is beautiful to all and inspiringly beautiful to some. Something that might take a different form depending on your point of view, but is inherently consistent. Something whose relevance and interpretation would need no explanation or elaboration. <br>

**Inconspicuous and Unambiguous**

![](https://lh3.googleusercontent.com/HbkU5h--yf2hR51eYV-wAg--o5H4gItVjgiDGeuNccVc_S2cgGQIeXWd_YnEjdle9feZIVA6YLnjhwgwSu3ZZ7MoTYGq0f8dM9cERqD2b-omfwgV9lyAs09T75wXHpy2A03IhL4e=s0)

The idea at the core of the design is the motif which is a radial composition of interlocking modules that take the shape of the map of India. The vertices and edges of the map outline were tweaked to cleanly obtain the desired composition with aligned and overlapping edges such that individual modules aren't immediately decipherable in neither the motif as a whole nor in any pattern comprising multiple motifs in a composition. While some creative liberties were taken with the extents of the territorial boundaries the resulting shape of the module is unambiguously perceived to be India. Adding another dimension to this idea, the three dimensional form is obtained by computationally projecting this motif onto each of the six sides of an imaginary dimpled and filleted cube.  The parametric model created as a result of this computationally scripted process can be scaled to something as large as a building or as small as a table top souvenir.

**Delicate and Strong**

![](https://lh6.googleusercontent.com/uXDrBF7iMq6pIjC5cS3b7KL9o-L2S8UhPAguc54Z7eya2uHEfJwC2dZnS0dXEWg6ZFX14j4BoLsY4UDGL8wgClTpSDs6hBLGh5W06TYFKJg3mlj6G8ByWLWLl-GVa939N_PBq1Vk=s0)

Hollow steel pipes, 2064 of them, each of a diameter that is about 0.32% of the overall width of the sculpture, makes up the structural skeleton. The needle-like relative proportion gives the dense steel framework a sense of lightness while exploiting the tensile properties of steel. The heat generated on account of the steel tubes being exposed to the sun is absorbed by the heatcrete filled within their hollow cores which collectively form a Thermal Energy Storage System. Heatcrete is a concrete-like energy storage material and also helps improve the compressive properties where required.The steelwork provides a frame and reference to which the panels are fixed. While the material of the panels could vary and adapt to different contexts and environments, they are responsible for providing the final flourish and would need to be determined with care. A generic material that should work adequately is architectural fabric. However if it were to be contextual to a culture or region, it could also be woven bamboo in Nagaland, sandstone in Rajasthan, coconut fiber in Kerala and so on.  Basically any material that adequately bridges the reference provided by the projecting steel tubes to form surfaces from which the form of India emerges. The base steel  framework, like India, is consistent, the constituents are dynamic and can be contextual.

{% file src="/files/-Mh8rxHPB5Ef5fYdWDTB" %}
Notions of India - Panels
{% endfile %}

The precisely positioned steel pipes are analogous to the land of India providing material and support for its inhabitants to flourish. While the inhabitants emotionally identify with this geography very strongly, it is the inhabitants that make this India. This sculpture conveys this cyclic, amorphous and symbiotic relationship between the land and its people. While the notion of India it attempts to convey could and should be interpreted differently, it without question will not fail to elicit an uplifting patriotic sentiment, only in an Indian.<br>

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MkjnuLnW9OdmEBk6d6r%2F-MkjrjcOh03DNeMgQO9p%2Findflorescence-2.png?alt=media\&token=555563fd-1394-4013-a08a-6c4824c9b40c)


# Rectangular Compartments

Divide an irregular closed polygon into component Rectangles

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MMoRmIZrUDCd89xZTr0%2F-MMoSNJs2lidQZvqsziV%2Fdivisions.gif?alt=media\&token=b921937f-fb71-42da-8ded-36a2c92ae3c4)

```d
def Rect(srf:var[]..[])
{
	srf01 = List.Flatten(srf.Explode(),-1);
	srf02 = List.FilterByBoolMask(srf01,List.Count(srf01.Vertices.PointGeometry<1>)>3)["in"];
	crv00 = srf02.PerimeterCurves();
	pcv01 = PolyCurve.ByJoinedCurves(crv00);
	vtx01 = List.Flatten(srf02.Vertices.PointGeometry,-1);

	//Offset Perimter Curves Outwards
	seg01 = 100;
	off01 = List.Flatten(crv00,-1)[0].Length/seg01;
	pcv02 = pcv01<1>.Offset([off01,-off01]);
	pcv03 = List.FirstItem(pcv02<1>);
	pcv04 = List.LastItem(pcv02<1>);
	pcv05 = pcv03.Length > pcv04.Length ? pcv03 : pcv04;

	//Inward Vectors
	acc01 = 8;
	pnt01 = crv00<1><2>.PointAtParameter((0..1..#acc01));
	vct00 = crv00<1><2>.NormalAtParameter((0..1..#acc01));
	vct01 = List.GetItemAtIndex(vct00<1><2>,Math.Floor(acc01/2));
	pnt02 = List.Flatten(pnt01.Project(pcv05,vct01)<1><2>,-1);
	bln01 = List.AllTrue((pnt01.DistanceTo(pnt02)!=off01)<1><2>);
	vct02 = bln01 ? vct01 : vct01.Reverse();

	//Rectangle aligned to Surface Boundaries
	pnt03 = List.Flatten(pnt01.Project(pcv05,vct02)<1><2>,-1);
	dis01 = Math.Round(pnt01.DistanceTo(pnt03)-off01,6);
	bln02 = List.DropItems(dis01<1><2>,-1)==List.DropItems(dis01<1><2>,1);
	fil01 = List.IndexOf(bln02<1><2>,true);
	fil02 = fil01==-1 ? acc01 : fil01;
	fil03 = List.DropItems(bln02<1><2>,fil02<1><2>);
	fil04 = List.IndexOf(fil03<1><2>,false);
	fil05 = fil04 == -1 ? acc01-1 : fil04+1;
	fil06 = List.DropItems(pnt01<1><2>,fil02<1><2>);
	pnt04 = List.TakeItems(fil06<1><2>,fil05<1><2>);
	fil07 = List.DropItems(pnt03<1><2>,fil02<1><2>);
	pnt05 = List.TakeItems(fil07<1><2>,fil05<1><2>);
	lin01 = List.Clean(Line.ByStartPointEndPoint(pnt04,pnt05).ExtendEnd(-off01),false);
	bln03 = List.Count(List.RemoveIfNot(lin01.Intersect(pcv01)<1><2><3>,"Point")<1><2><3>)>2;
	lin02 = List.FilterByBoolMask(lin01,bln03)["out"];
	lin03 = List.FirstItem(lin02<1><2>);
	lin04 = List.LastItem(lin02<1><2>);
	vct03 = Vector.ByTwoPoints(lin03.PointAtParameter(0.5),lin04.PointAtParameter(0.5));
	vct04 = Vector.ByTwoPoints(lin04.PointAtParameter(0.5),lin03.PointAtParameter(0.5));

	//Shift edge towards Closest Vertex
	pnt06 = List.Transpose(vtx01<3>.Project(lin03<1><2>,vct03<1><2>)<1>);
	bln04 = DSCore.Object.IsNull(List.Count(pnt06<1><2><3>)>0)?true:List.Count(pnt06<1><2><3>)>0;
	dis02 = lin03.DistanceTo(List.FilterByBoolMask(vtx01,bln04<1><2>)["in"]);
	lin05 = lin03.Translate(vct04,List.MinimumItem(dis02));
	pnt07 = List.Transpose(vtx01<3>.Project(lin04<2><1>,vct04<2><1>)<1>);
	bln05 = DSCore.Object.IsNull(List.Count(pnt07<1><2><3>)>0)?true:List.Count(pnt07<1><2><3>)>0;
	dis03 = lin04.DistanceTo(List.FilterByBoolMask(vtx01,bln05<1><2>)["in"]);
	lin06 = lin04.Translate(vct03,List.MinimumItem(dis03));

	//Largest Rectangle
	lin07 = List.Transpose([lin05,lin06]);
	edg01 = List.FirstItem(lin07<1>);
	edg02 = List.LastItem(lin07<1>);
	pnt08 = List.Transpose(List.Transpose([edg01.StartPoint,edg01.EndPoint,edg02.EndPoint,edg02.StartPoint])<1>);
	rct01 = Rectangle.ByCornerPoints(pnt08);
	are01 = rct01.Patch().Area;
	rct02 = List.LastItem(List.SortByKey(rct01<1>,are01<1>)["sorted list"]<1>);
	return rct02;
};

```

```d
def Divs(srf:var[]..[])
{
	divs = [Imperative]
	{
		c = 0;
		r = [];
		n = true;
		s = [];
		while (n)
		{
			r [c] = Rect(srf);
			sld01 = Surface.ByPatch(List.Flatten(r[c],-1));
			sld02 = Solid.ByUnion(Surface.Thicken(sld01,10));
			s [c] = Surface.SubtractFrom(srf,sld02);
			srf = List.Flatten(s[c],-1);
			n = List.Count(List.Flatten(r[c],-1))>0;
			c = c+1;

		}
		rct01 = List.DropItems(List.Flatten(r,-1),-1);
		prm01 = (List.LastItem(List.DropItems(List.Flatten(s,-1),-1)).Explode());
		return [rct01,prm01];
	}
	crv01 = PolyCurve.ByJoinedCurves(divs[1].PerimeterCurves());
	crv02 = List.Flatten([divs[0],crv01],1);


	return crv02;
};
```

{% file src="/files/-MMoTJmlcV55jA2FFL0o" %}
Dynamo 2.9
{% endfile %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MMoRmIZrUDCd89xZTr0%2F-MMoSw6CQ-bynEOGWDXo%2FRectangularDivision_2020-11-23_10-55-59.png?alt=media\&token=50ad8e97-7bb9-48ce-b024-612d78ed0f49)


# Retail Space Layout

Design Automation

![Retail Space Layout Automation](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MFlPakw75XUbbY1tfjq%2F-MFlRXmQ8yQhjjpLxep9%2FRetailSpacePlanning.gif?alt=media\&token=3719d34a-6daa-4545-9432-630a3e3f2b18)

{% file src="/files/-MFlSEfug6Txy5mLzEWC" %}

```d
// Functions
//
//Shift if obstructed
//
def aisles(clm:var,dir:var,dirShf:var,aisleEdg:var,aisleWid:var,
aisleMin:var,shiftInc:var,aisleGap:var,nos:var)
{
	return=[Imperative]
	{
		cnt = 0;
		aisle = [];
		while (cnt<nos)
		{
			clm2 = [];
			aisleSrf = [];
			aisleSrf1 = [];
			aisleStartEdg = [];
			shft = 0;
			clm1=clm.Translate(dirShf.Reverse(),aisleWid-aisleMin);
			clm2=PolySurface.ByJoinedSurfaces(clm.Intersect(clm1));
			aisleEndEdg = aisleEdg.Translate(dir,aisleWid);
			aisleSrf = Surface.ByLoft([aisleEdg,aisleEndEdg]);
			if (dir==dirShf)
			{
				while (clm2.DoesIntersect(aisleSrf))
				{
					shft = shft + shiftInc;
					aisleSrf = aisleSrf.Translate(dirShf,shft);
					aisleEndEdg = aisleEndEdg.Translate(dirShf,shft);
				}
				aisleStartEdg = aisleEdg;
				aisleSrf1 = Surface.ByLoft([aisleStartEdg,aisleEndEdg]);
				}
				else
				{
					while (clm2.DoesIntersect(aisleSrf))
					{
						shft = shft + shiftInc;
						aisleSrf = aisleSrf.Translate(dirShf,shft);
						aisleEndEdg = aisleEndEdg.Translate(dirShf,shft);
					}
					aisleStartEdg = aisleEndEdg.Translate(dirShf,aisleWid);
					aisleSrf1 = Surface.ByLoft([aisleStartEdg,aisleEndEdg]);
				}
			aisle[cnt] = [aisleStartEdg,aisleEndEdg,aisleSrf1];
			aisleEdg = aisleEndEdg.Translate(dir,aisleGap);
			cnt = cnt + 1;
			}
		return = aisle;
	}
};
//
//

//
//Module stacking
//
def modTrn(clm,dir,strEdg,gdlWid1,gdlWid2,gdlCnt,endkDpt)
{
	return = [Imperative]
	{
		edg002 = [];
		bln001 = [];
		bln002 = [];
		edg004 = [];
		edg011 = [];
		c = 0;
		edg00a = aisles(clm,dir,dir,strEdg,endkDpt,endkDpt,0.01,0,1);
		edg00b = List.TakeItems(Flatten(edg00a),2);
		edg00c = List.GetItemAtIndex(Flatten(edg00a),1);
		edg001 = aisles(clm,dir,dir,edg00c,gdlWid1,gdlWid1,gdlWid2,0,gdlCnt);
		for (i in edg001)
		{
			edg002[c] = List.GetItemAtIndex(i,0);
			c = c+1;
		}
		c=0;
		dis001 = strEdg.DistanceTo(edg002);
		for (i in dis001)
		{
			bln001[c] = i < (gdlWid1*gdlCnt)+gdlWid1;
			c = c+1;
		}
		c=0;
		edg003 = List.FilterByBoolMask(edg001,bln001)["in"];
		for (i in edg003)
		{
			edg004[c] = List.TakeItems(i,2);
			c = c+1;
		}
		c=0;
		edg005 = List.LastItem(Flatten(edg004));
		edg006 = aisles(clm,dir,dir,edg005,endkDpt,endkDpt,gdlWid2,0,1);
		edg007 = List.GetItemAtIndex(Flatten(edg006),1);
		edg008 = edg007.Translate(dir.Reverse(),endkDpt);
		edg0a8 = [edg008,edg005];
		edg009 = [edg008,edg007];

		edg010 = List.AddItemToEnd(edg009,List.AddItemToEnd(edg0a8,List.AddItemToFront(edg00b,edg004)));
		for(i in edg010)
		{
			bln002[c] = List.GetItemAtIndex(i,0).DoesIntersect(List.GetItemAtIndex(i,1));
			c = c+1;
		}
		edg011 = List.FilterByBoolMask(edg010,bln002)["out"];
		return = edg011;
	}
};
//
//

//
//Aisles and Modules
//
def modAsl(clm,dir,strEdg,endEdg,gdlWid1,gdlWid2,gdlCnt,endkDpt,aslWidIdl,aslWidMin)
{
	return = [Imperative]
	{
		c = 0;
		d = 0;
		dis002 = 0;
		gdlCnt01 = gdlCnt;
		aslEdg1 = [];
		aslEdg2 = [];
		aslEdg3 = [];
		dis001 = endEdg.DistanceTo(strEdg);
		aslEdge = strEdg;
		strEdg1 = strEdg;
		while (dis002<dis001)
		{
			if ((dis001-dis002) > ((gdlWid1*gdlCnt)+(endkDpt*2)+aslWidIdl))
			{
				gdlCnt01 = gdlCnt;
			}
			else
			{
				gdlCnt01 = Math.Floor((dis001-dis002-(endkDpt*2)-aslWidIdl)/(gdlWid1));
			}
			aslEdg1[c] = modTrn(clm,dir,strEdg1,gdlWid1,gdlWid2,gdlCnt01,endkDpt);
			aslEdg2[c] = List.LastItem(Flatten(aslEdg1[c]));
			aslEdg3[c] = Flatten(aisles(clm,dir,dir,aslEdg2[c],aslWidIdl,aslWidMin,0.01,0,1))[1];
			strEdg1 = aslEdg3[c];
			dis002 = strEdg1.DistanceTo(strEdg);
			c = c+1;
			d = d+5;

		}
		return = aslEdg1;
	}
};
//
//
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MFlPakw75XUbbY1tfjq%2F-MFlS5UD8nqFOiS-HKcq%2F20170511-1_2020-08-28_01-15-02.png?alt=media\&token=0cb13673-cb51-48bf-8e93-2b6e82821b90)

```
//Alignment and Direction Control
flip = false;
frToRr = true;
lfToRg = true;

//Wall Fixture Depths
wallFxtRear = 0.48;
wallFxtLeft = 0.48;
wallFxtFrnt = 0.48;
wallFxtRght = 0.48;

//Gondola Dimensions
gndlWid001 = 1;
gndlWid002 = 0.5;
gndlDpt001 = 0.75;
gndlCntMax = 12;
endkDpt001 = 0.5;

//Aisle Widths
aslWidIdl = 2.4;
aslWidMin = 1.2;

//Boundary Perimeter
bnd001 = Rectangle.ByWidthLength(80,50);

//Columns
//clm001 = Rectangle.ByWidthLength(0.6,0.9);
clm001 = Rectangle.ByWidthLength(1,1);
clm002 = clm001.Translate(Vector.YAxis(),[-24,-13,0,12,24]);
clm003 = clm002<1>.Translate(Vector.XAxis(),(-36..36..12)<2>);
clm004 = Surface.ByPatch(Flatten(clm003));
clm005 = PolySurface.ByJoinedSurfaces(clm004);

//Boundary Edges
crv001 = bnd001.Explode();
rghtEdg0 = crv001[0];
rearEdg0 = crv001[1];
leftEdg0 = crv001[2];
frntEdg0 = crv001[3];

rghtEdg = flip?frntEdg0:rghtEdg0;
rearEdg = flip?leftEdg0:rearEdg0;
leftEdg = flip?rearEdg0:leftEdg0;
frntEdg = flip?rghtEdg0:frntEdg0;

//Directions
pnt001 = rearEdg.PointAtParameter(0.5);
pnt002 = frntEdg.PointAtParameter(0.5);
pnt003 = leftEdg.PointAtParameter(0.5);
pnt004 = rghtEdg.PointAtParameter(0.5);
dir001 = Vector.ByTwoPoints(pnt001,pnt002);
dir002 = Vector.ByTwoPoints(pnt002,pnt001);
dir003 = Vector.ByTwoPoints(pnt003,pnt004);
dir004 = Vector.ByTwoPoints(pnt004,pnt003);

//Trimmed Boundary Edges
rearEdg001 = Flatten(rearEdg.Trim(leftEdg.Translate(dir003,wallFxtLeft),rearEdg.Intersect(leftEdg)));
rearEdg002 = Flatten(rearEdg001.Trim(rghtEdg.Translate(dir004,wallFxtRght),rearEdg.Intersect(rghtEdg)));
frntEdg001 = Flatten(frntEdg.Trim(leftEdg.Translate(dir003,wallFxtLeft),frntEdg.Intersect(leftEdg)));
frntEdg002 = Flatten(frntEdg001.Trim(rghtEdg.Translate(dir004,wallFxtRght),frntEdg.Intersect(rghtEdg)));
leftEdg001 = Flatten(leftEdg.Trim(rearEdg.Translate(dir001,wallFxtRear),leftEdg.Intersect(rearEdg)));
leftEdg002 = Flatten(leftEdg001.Trim(frntEdg.Translate(dir002,wallFxtFrnt),leftEdg.Intersect(frntEdg)));
rghtEdg001 = Flatten(rghtEdg.Trim(rearEdg.Translate(dir001,wallFxtRear),rghtEdg.Intersect(rearEdg)));
rghtEdg002 = Flatten(rghtEdg001.Trim(frntEdg.Translate(dir002,wallFxtFrnt),rghtEdg.Intersect(frntEdg)));

//Rear Wall Fixtures
rearEdg003 = rearEdg002.Translate(dir001,wallFxtRear);
rearAsl001 = Flatten(aisles(clm005,dir001,dir001,rearEdg003,aslWidIdl,aslWidMin,0.01,0,1));
rearEdg004 = rearAsl001[1];

//Left Wall Fixtures
leftEdg003 = List.FirstItem(leftEdg002.Translate(dir003,wallFxtLeft));
//leftAsl001 = Flatten(aisles(clm005,dir003,dir003,leftEdg003,aslWidIdl,aslWidMin,0.01,0,1));
//leftEdg004 = leftAsl001[1];

//Front Wall Fixtures
frntEdg003 = frntEdg002.Translate(dir002,wallFxtFrnt);
frntAsl001 = Flatten(aisles(clm005,dir002,dir002,frntEdg003,aslWidIdl,aslWidMin,0.01,0,1));
frntEdg004 = frntAsl001[1];

//Right Wall Fixtures
rghtEdg003 = List.FirstItem(rghtEdg002.Translate(dir004,wallFxtLeft));
rghtAsl001 = Flatten(aisles(clm005,dir004,dir004,rghtEdg003,aslWidIdl,aslWidMin,0.01,0,1));
rghtEdg004 = rghtAsl001[1];

//Module Stacking - Longer
frRrMd001 = modAsl(clm005,dir002,frntEdg004,rearEdg,gndlWid001,gndlWid002,gndlCntMax,endkDpt001,1.8,1.2);
frntEdg006 = List.FirstItem(frRrMd001<1><2>);

//Module Stacking - Shorter
leftNos001 = ((leftEdg003.DistanceTo(rghtEdg003))/((gndlDpt001*2)+aslWidIdl))+1;
leftAsl002 = aisles(clm005,dir003,dir003,leftEdg003,aslWidIdl,aslWidMin,0.01,gndlDpt001*2,leftNos001);
leftEdg006 = List.TakeItems(leftAsl002<1>,2);
leftEdg007 = List.FirstItem(leftEdg006 <1>);
bln11 = leftEdg003.DistanceTo(leftEdg007)<leftEdg003.DistanceTo(rghtEdg003);
leftEdg008 = Transpose(List.FilterByBoolMask(leftEdg006,bln11)["in"]);
leftEdg009 = List.DropItems(List.LastItem(leftEdg008),-1).Translate(dir003,gndlDpt001);

//Module Placement Points
mdulPnt001 = Flatten((frntEdg006<1>.Intersect(leftEdg009<2>))<1><2>);
mdulPnt002 = List.DropItems(mdulPnt001<1><2>,1);
mdulPnt003 = List.DropItems(List.Sublists(mdulPnt002<1><2>,0..1,1)<1><2>,-1);
mdulPnt004 = List.FirstItem(mdulPnt003<1><2><3>);
mdulPnt005 = List.LastItem(mdulPnt003<1><2><3>);
mdulDis001 = Math.Round((mdulPnt004).DistanceTo(mdulPnt005),2);
mdulDis002 = List.Reverse((0..#(Math.Ceiling(mdulDis001))..gndlWid001)<1><2><3>);
mdulPnt008 = Flatten(mdulPnt005.Translate(dir001,mdulDis002)<1><2>);
//Module Start-End Points
mdulPnt009 = List.AddItemToFront(List.FirstItem(mdulPnt004<1><2>)<1><2>,mdulPnt008<1><2>);
mdulPnt010 = List.DropItems(List.Sublists(mdulPnt009<1><2>,0..1,1)<1><2>,-1);
mdulPnt011 = List.FirstItem(mdulPnt010<1><2><3>);
mdulPnt012 = List.LastItem(mdulPnt010<1><2><3>);
//Module Placement Points
mdulDis003 = Math.Round((mdulPnt011).DistanceTo(mdulPnt012),2);
mdulPnt013 = mdulDis003==gndlWid001?mdulPnt009.Translate(dir002,gndlWid001/2):mdulPnt009.Translate(dir002,gndlWid002/2);
//Placeholder Rectangles (To be deleted once Families are loaded)
mdulFml001 = Rectangle.ByWidthLength(Plane.ByOriginNormal(mdulPnt013,Vector.ZAxis()),gndlWid001,gndlDpt001*2);
mdulFml002 = Rectangle.ByWidthLength(Plane.ByOriginNormal(mdulPnt013,Vector.ZAxis()),gndlWid002,gndlDpt001*2);
mdulTyp001 = mdulDis003==gndlWid001?mdulFml001:mdulFml002;
//Module Rotation
mdulCir001 = Circle.ByCenterPointRadius(mdulPnt013,gndlDpt001);
mdulPnt014 = List.Clean((leftEdg009<1>.Intersect(mdulCir001<2>))<1><2>,false);
mdulDir001 = Vector.ByTwoPoints(List.FirstItem(mdulPnt014<1><2><3><4>),List.LastItem(mdulPnt014<1><2><3><4>));
mdulDir002 = Flatten(Transpose(mdulDir001)<1><2>);
mdulAng001 = Vector.XAxis().AngleWithVector(mdulDir002);
mdulTyp002 = mdulTyp001.Rotate(Plane.ByOriginNormal(mdulPnt013,Vector.ZAxis()),-mdulAng001);
mdulTyp003 = List.FilterByBoolMask(mdulTyp002,mdulTyp002.DoesIntersect(clm005))["out"];
```


# Noise Barrier : Swedevia Airport

Noise Barrier

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-GOTjuoktkmV1U7X%2FSwedavia-1.jpg?alt=media\&token=01db814b-4acd-4eb0-8245-29ff05966b03)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-S1y5qvwt0JwUU91%2Fswedavia-2.jpg?alt=media\&token=8654e1b7-a500-4699-8f40-ea94ae507e1f)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-ULNAtrpDdumtNFC%2FSwedavia-3.jpg?alt=media\&token=ad807827-bd6b-4614-95ff-e50b06fcb502)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-Wd6jYGBtYgrgalq%2FSwedavia-5.jpg?alt=media\&token=ecdb30d8-6988-4b6d-9f76-cadc1bf73f5a)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-ZfcDSR9JQqEd5ch%2FSwedavia-6.jpg?alt=media\&token=8d9e7fb7-9282-4e8a-8bdf-fd03818bf725)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8zTXo19r0OE8b1W9e%2F-Lh9-amBVn2OK7nkJM_K%2FSwedavia-7.jpg?alt=media\&token=f63d6c19-9949-461d-ba63-af7661472927)


# Walden

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgQyALw6JdYoP93Bc%2Fw1.jpg?alt=media\&token=7af31f9d-157d-47ed-849a-085bcb6ae566)

```d
//Tank Position
TankCen=Point.ByCoordinates(0,0,720.5);
Vantage=TankCen.Translate(Vector.ZAxis(),5.5);
Base=TankCen.Translate(Vector.ZAxis(),2);

//Shrine positions
Anjanaya=Point.ByCoordinates(64.982,224.412,741.821);
Ganesha=Point.ByCoordinates(7.910,200.187,742.974);
ShivaLinga=Point.ByCoordinates(-3.873,42.791,722.440);
Subramanya=Point.ByCoordinates(-101.993,227.327,750.097);
Shiva=Point.ByCoordinates(-516.424,-23.435,678.037);
Dhanwanthari=Point.ByCoordinates(-88.529,-21.002,713.843);
Buddha=Point.ByCoordinates(-508.277,-149.171,661.635);
Nagas=Point.ByCoordinates(-385.322,-165.240,680.901);
Vanadevatha=Point.ByCoordinates(-360.374,-177.952,684.753);
Jesus=Point.ByCoordinates(-144.263,-97.897,711.005);
Krishna=Point.ByCoordinates(-21.942,-36.820,720.496);

Shrines=[Krishna,Jesus,Vanadevatha,Nagas,Buddha,Dhanwanthari,Shiva,Subramanya,ShivaLinga,Ganesha,Anjanaya];
ShrineConnect=Line.ByStartPointEndPoint(Vantage,Shrines);

GridSpacing=1;
GridMinRadius=6;
GridMaxRadius=16;

//BaseGrid
BaseGrid=Point.ByCoordinates((-20..20..GridSpacing)<1>,(-20..20..GridSpacing)<2>,Base.Z);
BaseDist=BaseGrid.DistanceTo(Base);

Cyl1=Cylinder.ByPointsRadius((Point.ByCoordinates(0,0,600)),(Point.ByCoordinates(0,0,800)),GridMaxRadius);
Cyl2=Cylinder.ByPointsRadius((Point.ByCoordinates(0,0,600)),(Point.ByCoordinates(0,0,800)),GridMinRadius);
Cyl=Cyl1.Difference(Cyl2);
ShrineRidges=Flatten(Cyl.Intersect(ShrineConnect));
ShrineConnectSurf=Surface.ByRuledLoft(ShrineRidges);
ShrineConnectSurfExp=ShrineConnectSurf.Explode();

//Extents of Walls
ShrineSurfPnts1=ShrineConnectSurfExp<1>.Intersect(Flatten(BaseGrid.Project(ShrineConnectSurf,Vector.ZAxis()))<2>);
ShrineSurfPnts=Flatten(ShrineSurfPnts1<1>);

GrdBndBx=(BoundingBox.ByGeometry(Flatten(ShrineSurfPnts1)));
GrdBndBxMx=GrdBndBx.MaxPoint;
GrdBndBxMn=GrdBndBx.MinPoint;

//Extent of Roof
ShrineRf=Flatten([(Point.ByCoordinates(110.499,-206.013,701.623)),Shrines,(Point.ByCoordinates(207.827,121.375,710.844))]);
ShrineRfConnect=Line.ByStartPointEndPoint(Vantage,ShrineRf);
CylRf=Cylinder.ByPointsRadius((Point.ByCoordinates(0,0,600)),(Point.ByCoordinates(0,0,800)),(GridMaxRadius+2));
ShrineRfRidges=Flatten(CylRf.Intersect(ShrineRfConnect));
ShrineRfConnectSurf=Surface.ByLoft(ShrineRfRidges);

//Group by Height Range-Walls
h1=[725.00,726.30];
h2=[725.62,727.50];
PnGrBl1=(ShrineSurfPnts<1>.Z)>h1<2>&&(ShrineSurfPnts<1>.Z)<h2<2>;
PntGrp1=List.FirstItem(List.FilterByBoolMask(ShrineSurfPnts,PnGrBl1<1>)<1>);
PntGrp=Transpose(PntGrp1);

SldDivsPnt=Flatten(PntGrp);
SldDivsPntsGrd=Point.ByCoordinates(SldDivsPnt.X,SldDivsPnt.Y,Base.Z);
SldDivsBasePln=Plane.ByOriginNormal(Base,Vector.ZAxis());
SldDivsBasePro=Rectangle.ByWidthLength(CoordinateSystem.ByOrigin(SldDivsPntsGrd),GridSpacing,GridSpacing);
SldDivsBaseSol1=SldDivsBasePro.ExtrudeAsSolid(Vector.ZAxis(),1);
SldDivsBaseSol2=Solid.ByUnion(SldDivsBaseSol1);
SldDivsBaseSurf=SldDivsBaseSol2.IntersectAll(SldDivsBasePln);
SldDivsBasePerCrv=SldDivsBaseSurf.PerimeterCurves();
SldDivsBasePerPnt=SldDivsBasePerCrv.StartPoint;
SldDivsBasePerNur=NurbsCurve.ByControlPoints(SldDivsBasePerPnt,1,true);
SldDivs1=SldDivsBasePerNur.ExtrudeAsSolid(Vector.ZAxis(),3);
SldDivs=Solid.ByUnion(List.Clean(Flatten(SldDivs1),false));
SldDivsFlr=SldDivs.IntersectAll(Plane.ByOriginNormal(Base,Vector.ZAxis()));
BasePerCrv=SldDivsFlr.PerimeterCurves();
BasePerPnt=BasePerCrv.StartPoint;
BasePerNur=NurbsCurve.ByControlPoints(BasePerPnt,9,true);
BaseSol1=BasePerNur.ExtrudeAsSolid(Vector.ZAxis(),6);
BaseSol2=BasePerNur.ExtrudeAsSolid(Vector.ZAxis(),[-0.75,-0.3,-3.0]);
BaseSol3=BaseSol1.Union(BaseSol2);
BaseSol4=(List.Transpose(BaseSol3.Split(ShrineRfConnectSurf)))[0];

//Frames and Stilts
PntsParm=[(0.275..0.475..#5),(0.145..0.3..#4),(-0.01..0.35..#4)];
StltHt=[3.6,3,0.25];
FrmIntPln=BasePerNur.PlaneAtParameter(PntsParm);
frminoff=0.30;
frmoutoff=0.15;
frmthk=0.3;
SolThnShl=BaseSol4.ThinShell(frminoff,frminoff);
FrmSur=Flatten(SolThnShl.Intersect(FrmIntPln)<1>);
FrmSol1=FrmSur.Thicken(frmthk,true);
FrmSol2=Solid.ByUnion(FrmSol1);
SolCutPnt=(BoundingBox.ByGeometry(BaseSol4).MinPoint).Translate(Vector.ZAxis(),frminoff+3);
SolCutPln=Plane.ByOriginNormal(SolCutPnt,Vector.ZAxis());
StltSur=FrmSol2.Intersect(SolCutPln);
StltSol=StltSur.Thicken(-(0.1+StltHt),false);
FrmSol3=FrmSol2.UnionAll(StltSol);
Frms=FrmSol3.Translate(Vector.ZAxis(),-(frminoff));
BaseSol5=BaseSol4.DifferenceAll(Frms);

//Floor Area
SldDivsAre=Flatten(SldDivsFlr.Area);

//Roofs
Rfh1=[725.00];
Rfh2=[727.50];
RfPnGrBl1=(ShrineSurfPnts<1>.Z)>Rfh1<2>&&(ShrineSurfPnts<1>.Z)<Rfh2<2>;
RfPntGrp1=List.FirstItem(List.FilterByBoolMask(ShrineSurfPnts,RfPnGrBl1<1>)<1>);
RfPntGrp=Transpose(RfPntGrp1);
RfDivsPnt=Flatten(RfPntGrp);
RfDivsPntsGrd=Point.ByCoordinates(RfDivsPnt.X,RfDivsPnt.Y,Base.Z);
RfDivsBasePln=Plane.ByOriginNormal(Base,Vector.ZAxis());
RfDivsBasePro=Rectangle.ByWidthLength(CoordinateSystem.ByOrigin(RfDivsPntsGrd),GridSpacing,GridSpacing);
RfDivsBaseSol1=RfDivsBasePro.ExtrudeAsSolid(Vector.ZAxis(),1);
RfDivsBaseSol2=Solid.ByUnion(RfDivsBaseSol1);
RfDivsBaseSurf=RfDivsBaseSol2.IntersectAll(RfDivsBasePln);
RfDivsBasePerCrv=RfDivsBaseSurf.PerimeterCurves();
RfDivsBasePerPnt=RfDivsBasePerCrv.StartPoint;
RfDivsBasePerNur=NurbsCurve.ByControlPoints(RfDivsBasePerPnt,1,true);
RfDivs1=RfDivsBasePerNur.ExtrudeAsSolid(Vector.ZAxis(),3);
RfDivs=Solid.ByUnion(Flatten(List.Clean(RfDivs1,false)));
RfDivsFlr=RfDivs.IntersectAll(Plane.ByOriginNormal(Base,Vector.ZAxis()));
RfPerCrv=RfDivsFlr.PerimeterCurves();
RfPerPnt=RfPerCrv.StartPoint;
RfPerNur=NurbsCurve.ByControlPoints(RfPerPnt,10,true);
RfPerCur=RfPerNur.Offset(1.5);
RfSol1=RfPerCur.ExtrudeAsSolid(Vector.ZAxis(),6);
RfSur=Flatten(RfSol1.IntersectAll(ShrineRfConnectSurf));
RfSol=RfSur.Thicken(-0.1);
//RfSur=PolySurface.ByJoinedSurfaces(RfSur1);

//Extent of Openings
/*
FilPth="E:\\Projects\\India\\2015-AR01-WAL\\Dynamo\\SolarData\\Walden-";
OpnExt1=InsValOpn(120000,200000,4.5,5.0,723.0,1.5,1.5,FilPth+"1.csv");
OpnExt2=InsValOpn(120000,200000,4.5,4.0,721.0,1.5,1.5,FilPth+"2.csv");
OpnExt3=InsValOpn(120000,225000,4.5,4.0,723.5,1.5,1.5,FilPth+"3.csv");
OpnExt={OpnExt1,OpnExt2,OpnExt3};

BaseSol6=BaseSol5.DifferenceAll(OpnExt);
BaseSol7=BaseSol5.DifferenceAll(BaseSol6);

Elements=Flatten({BaseSol6,BaseSol7,Frms,RfSol});
*/;
```

```d
//Function-Openings based on solar insolation values
def InsValOpn(InsMin,InsMax,RecWidFac,RecLenFac,BaseMin,WidPow,LenPow,FlPth)
{
InsPnt=ImportFromCSV(FlPth);
InsolationValue=InsPnt[0];
InsRefPnt=Point.ByCoordinates(InsPnt[1]/3.28084,InsPnt[2]/3.28084,InsPnt[3]/3.28084);
InsRefDir=Vector.ByCoordinates(InsPnt[4]/3.28084,InsPnt[5]/3.28084,InsPnt[6]/3.28084);
//Filter points based on Z coordinate
MaskZ=(InsRefPnt.Z)>BaseMin;
InsValBas=List.FilterByBoolMask(InsolationValue,MaskZ)["in"];
InsPntBas=List.FilterByBoolMask(InsRefPnt,MaskZ)["in"];
InsDirBas=List.FilterByBoolMask(InsRefDir,MaskZ)["in"];
//Filtering points based on Insolation Values range
Mask=InsValBas>InsMin&&InsValBas<InsMax;
InsValFil=List.FilterByBoolMask(InsValBas,Mask)["in"];
InsPntFil=List.FilterByBoolMask(InsPntBas,Mask)["in"];
InsDirFil=List.FilterByBoolMask(InsDirBas,Mask)["in"];
//Rectangular Opening
RecBndSin=Rectangle.ByWidthLength(Plane.ByOriginNormal(InsPntFil,InsDirFil),RecWidFac/Math.Pow(InsValFil/100000,WidPow),RecLenFac/Math.Pow(InsValFil/100000,LenPow));
RecSurSin=Surface.ByPatch(RecBndSin);
RecSldSin=RecSurSin.Thicken(1,true);
OpnSldCom=Solid.ByUnion(RecSldSin);
return=OpnSldCom;
};
```

{% file src="/files/-LhLgKrvVkS3TYTPvLod" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgTbRgHZw4qdJSAA3%2Fw2.jpg?alt=media\&token=dccaaa21-1f63-413d-9507-5052ee46035a)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgXJUOpPzvmuVUKau%2Fw3.jpg?alt=media\&token=7231f8ea-1646-4d65-913e-883094387c42)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgZZwQYvOO7OwaY9e%2Fw4.jpg?alt=media\&token=6b65ec81-f6bc-4d51-bcc3-22378bbe462f)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgc04dz0dAL5eo1q0%2Fw5.jpg?alt=media\&token=e61f73f4-325d-4e0e-a8ed-283e18ac4248)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLge6SCtOX_QCGmkZA%2Fw6.jpg?alt=media\&token=9053862a-f899-44f5-9fce-8a99bd56101c)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLggJCAwZuPvT4pQMx%2Fw7.jpg?alt=media\&token=e02ee60b-68d9-4d16-b51a-b64db7f8eb49)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgiQA9DarU_ZP5aZT%2Fw8.jpg?alt=media\&token=39b8a61d-7363-4679-93f4-7ef0e41ba8f9)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgkhU737P2uEBz5bQ%2Fw9.jpg?alt=media\&token=23e310ff-101b-42f4-b9a3-f62c4b0346d1)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgnLDRRNJ56yF5Zs5%2Fw10.jpg?alt=media\&token=0147dbb1-2f32-4f26-a212-bccb7bc2ccfa)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgqRZrItr-5jDYDM8%2Fw11.jpg?alt=media\&token=56bb8aef-3ac4-4ef9-892c-44be568147fd)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgstXabrKStr2AfjD%2Fw12.jpg?alt=media\&token=fbe450b8-3be4-4b1a-bdaa-26568d4b6caf)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLg1YV-HkNyAo9mwz_%2F-LhLgvFiCZMUPuGZHbfx%2Fw13.jpg?alt=media\&token=d9810813-e3fb-40ed-800f-308e3c9e0024)


# Wilson Garden

Bengaluru Streets for People Challenge (February 2021)

The objective is to create a parametric tool that computationally applies design intent to any neighborhood and generates multiple design iterations driven by relevant input parameters such as the existing layout and parking space requirements. <br>

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnZxDImrgIM7khaEo8%2F-MUn_fj_4ZFHP-bfmOFj%2FSheet%201%20-%20Sheet%201.jpg?alt=media\&token=4c4aaa5b-10e2-452a-9744-cf191ab81d24)

The tool groups existing blocks into clusters referred to as Pedestrian Blocks that are bound by one-way streets for vehicular movement and parking. Every generated iteration provides information about the area of the Pedestrian Blocks and the number of Parking Spaces for that particular iteration.<br>

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUn_ib7XZmcswn26lKX%2F-MUn_maMWRpuZ2tXYwEy%2FSheet%202%20-%20Sheet%202.jpg?alt=media\&token=8fb672c6-044f-4a17-a670-1b1eee900662)

In addition to the Pedestrian Blocks, mentioned earlier the design proposal introduces the concept of an Asteroid which is a super elliptical shaped garden located at every vehicular intersection and enforces one directional traffic flow across the neighborhood. The introduction of multiple such gardens across the neighborhood should do some justice to the name the neighborhood carries.<br>

{% tabs %}
{% tab title="01" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUn_pD1i7H882-Y22Dn%2F-MUnaDKDxn8zw_jxaKCq%2F01%20-%20STREETS%20FOR%20PEOPLE%20CHALLENGE.jpg?alt=media\&token=e31d2d54-7915-4360-9b0c-46a8d9096782)

{% endtab %}

{% tab title="02" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUn_pD1i7H882-Y22Dn%2F-MUnaLxa7lce4gxWDcuK%2F02%20-%20Objective.jpg?alt=media\&token=a77a3475-e80f-4a3f-a135-f48c56e1970b)

{% endtab %}

{% tab title="03" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUn_pD1i7H882-Y22Dn%2F-MUnaaMDmndXpjePtYeR%2F03%20-%20Approach.jpg?alt=media\&token=5b1d4849-d8d1-4e78-a842-cc19631ad4a7)
{% endtab %}

{% tab title="04" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUn_pD1i7H882-Y22Dn%2F-MUnaeIZ2cwoQ--8xZVY%2F04%20-%20Benefits.jpg?alt=media\&token=29653f8e-6d9c-4018-a638-b200165d1afd)
{% endtab %}

{% tab title="05" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnajshH77LJ13-qDnH%2F05%20-%20Parametric%20Iteration.jpg?alt=media\&token=866caaec-381a-4044-a69c-365e649c08f2)
{% endtab %}

{% tab title="06" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnap12vxUKfOtW7Ljj%2F06%20-%20Parametric%20Iteration.jpg?alt=media\&token=dd08d220-f52e-40b4-b2b8-990ce1eb6597)
{% endtab %}

{% tab title="07" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnasKDCTSV6q1Bah5o%2F07%20-%20Parametric%20Iteration.jpg?alt=media\&token=f76a4633-7cae-47d0-82b7-4af1d28ecee2)

{% endtab %}

{% tab title="08" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnaveKk8sJyprr2ozX%2F08%20-%20Parametric%20Iteration.jpg?alt=media\&token=35e8e4d2-ba3b-4051-96ae-7372514369e4)

{% endtab %}

{% tab title="09" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnb39LdqhsQxE98yqh%2F09%20-%20Parametric%20Iteration.jpg?alt=media\&token=b3c31314-bd50-4823-b899-92a1e188163e)

{% endtab %}

{% tab title="10" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnb6l-1ZE7XvPQMuTW%2F10%20-%20Parametric%20Iteration.jpg?alt=media\&token=2d258630-19f7-49b1-89d0-0b98542b08f2)

{% endtab %}
{% endtabs %}

The one directional flow is to ensure continuous movement of traffic without any crisscrossing or directional conflict at any intersection. Traffic effectively moves in circles around Pedestrian blocks and the shortest vehicular route between any two Pedestrian Blocks within the neighborhood is a zigzag. However it continues to be direct and straight for cyclists and pedestrians who can cut across Pedestrian Blocks. This maze of one-ways should also serve to discourage through traffic.<br>

{% tabs %}
{% tab title="11" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnbBsoW3MYJ8OnpI_F%2F11%20-%20Green%20Path.jpg?alt=media\&token=9c156831-2d0d-45d7-b4fe-45c93d123939)
{% endtab %}

{% tab title="12" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnagTq2hSwYVepjkiL%2F-MUnbz1klTEex9tYf6Ha%2F12%20-%20One%20Way%20Streets.jpg?alt=media\&token=ae99c175-002e-4752-95db-9997739107ae)

{% endtab %}

{% tab title="13" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUnc4IVhNJzydWs1SFQ%2F13%20-%20Concept.jpg?alt=media\&token=056bfd80-16b3-4757-8e5b-c8412dba45f2)

{% endtab %}

{% tab title="14" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUnc8fWp-owskQO_dUF%2F14%20-%20Asteroid.jpg?alt=media\&token=231b79c6-fd6c-4ca8-b5f6-7ac0b54f9b6f)

{% endtab %}

{% tab title="15" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUncCX6_5-k7bOG8t5R%2F15%20-%20Implementation.jpg?alt=media\&token=a57765c7-dfa6-4266-aebf-83eaef702e1d)

{% endtab %}

{% tab title="16" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUncGGNhz1PpUzi-FqR%2F16%20-%20Implementation.jpg?alt=media\&token=00195c2f-1187-4963-83c4-ccf5cd146108)

{% endtab %}

{% tab title="17" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUncKfz0Z1LY6moF_M_%2F17%20-%20Cost%20and%20Phases.jpg?alt=media\&token=bb3e757b-9111-466f-b6a9-4cd80da6a311)

{% endtab %}

{% tab title="18" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUncOeyyyn69jl7Lnq0%2F18%20-%20Next%20Steps.jpg?alt=media\&token=4d39c6c7-ab4e-42f0-b032-d244c6956f5c)

{% endtab %}

{% tab title="19" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUncTLyQU-tYpK6dCgf%2F19%20-%20Appendix%20-%20Sample%20Code.jpg?alt=media\&token=ec1eea29-d300-44d7-8367-6f0caf58c2c5)

{% endtab %}

{% tab title="20" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MUnc006HqW4kuHbZaV0%2F-MUncWxkhOoI84C4k43z%2F20%20-%20Appendix%20-%20Sample%20Code.jpg?alt=media\&token=f1e3badb-c61e-4230-bc92-6cab8464f299)

{% endtab %}
{% endtabs %}

The computational iterations are based on hard coded design intent and should necessarily be reviewed by the community to refine and correct any obvious faults and shortcomings that a purely parametrically driven design approach could throw up. However the advantage of such an approach is that discussions with the concerned community would not be based on a particular design being imposed on them, but with a tool that enables them to evaluate and refine multiple options within the framework of a broad design concept.<br>

{% tabs %}
{% tab title="Design Script" %}

```d
/*
Road Width for One Side Parallel Parking : 8m
Road Width for Two Side Parallel Parking : 10.0m
Stall Intervals 7.0m, Stall Width: 2.0m, Aisle Width 2.5m, Lane Width 3.5m

Road Width for One Side 30 degree Parking : 12m
Stall Intervals 5.5m, Stall Width 5.0m,Aisle Width 3.5m, Lane Width 3.5m
*/

//Control Variables
//Max Block Area
mxa01 = (Math.PI*Math.Pow(400000,2)/1000000)/23;
//Lane Width
lnW01 = 2800;
//Turning Radius
tnR01 = 7000;
//Parallel Parking
pkW01 = 2400;
pkL01 = 7000;

//Deserialize blocks as Surfaces
blk01 = List.Flatten(Geometry.DeserializeFromSAB(DSOffice.Data.ImportCSV("G:\\My Drive\\Bengaluru-Competition\\Shantinagar\\Design\\20210208.csv",false)),-1);
blk02 = Blks04((Blks03(List.ShiftIndices(blk01,1),mxa01)),mxa01);

//Perimeter Curves
prm01 = PolyCurve.ByJoinedCurves(PolySurface.ByJoinedSurfaces(blk01).PerimeterCurves());
prm02 = PolyCurve.ByJoinedCurves(blk02.PerimeterCurves());
prm03 = prm02.Offset(-lnW01);
prm04 = prm03.Fillet(tnR01,false).Fillet(tnR01,true);
prm05 = prm04.Offset(-pkW01);

//Number of Car Parking spaces including periphery
crP01 = Math.Sum(List.Flatten(Math.Floor(List.RemoveIfNot(prm05.Explode()<1>,"Line").Length/pkL01),-1));

//Number of Car Parking spaces excluding main roads
crP02 = crP01 - Math.Floor((prm01.Length/2)/pkL01);

//Graphics
ctl01 = PolySurface.ByJoinedSurfaces(List.Flatten(blk01.PerimeterCurves().Extrude(Vector.ZAxis()),-1));

prk01 = Surface.ByLoft(List.Transpose([prm04,prm05]));
blk03 = prm05.Patch();
int01 = ctl01.Intersect(blk03);

//Color
clr01 = GeometryColor.ByGeometryColor(prk01,Color.ByARGB(255,0,0,255));
clr02 = GeometryColor.ByGeometryColor(blk03,Color.ByARGB(255,255,255,0));
clr03 = GeometryColor.ByGeometryColor(int01,Color.ByARGB(50,255,0,0));

[clr01,clr02,clr03];
```

{% endtab %}

{% tab title="Functions" %}

```d
def Blks01(blks:var[]..[],mxar)
{
	//Adjacent blocks with a common junction and total area less than max
	blk00 = List.SortByKey(blks,blks[0].DistanceTo(blks))["sortedList"];
	return [Imperative]
	{
		ind01 = 0;
		ind02 = 0;
		are01 = 0;
		blk01 = [];
		blk02 = [];
		for (i in blk00)
		{
			if(i.DistanceTo(blk00[0])==0 && are01 < mxar)
			{
				blk01[ind01] = i;
				ind01 = ind01 + 1;
				are01 = i.Area/1000000 + are01;
			}
			else
			{
				blk02[ind02] = i;
				ind02 = ind02 + 1;
			}
		}
		return List.Flatten([PolySurface.ByJoinedSurfaces(blk01),blk02],-1);
	}
};

def Blks02 (blks:var[]..[],mxar)
{
	//Additional blocks if adjacent junction blocks area less than max
	blk1 = [Imperative]
	{
		blk00 = Blks01(blks,mxar);
		are01 = blk00[0].Area/1000000;
		blk01 = [];
		bln01 = List.Count(blks) != List.Count(blk00);
		while (are01 < mxar && bln01)
		{
			are01 = blk01[0].Area/1000000;
			blk01 = Blks01(blk00,mxar);
			for (i in List.RestOfItems(blk01))
			{
				bln00 = (i.DistanceTo(blk01[0])==0) || false;
			}
			bln01 = bln00 && List.Count(RestOfItems(blk01))>0;
			blk00 = blk01;
		}
		//return blk01;
		return blk00;
	}

	blk2 = List.Count(blk1)>0?List.SortByKey(blk1,blk1[0].DistanceTo(blk1))["sortedList"]:blk1;
	return blk2;
};
```

{% endtab %}

{% tab title="Functions" %}

```d
def Blks03 (blks:var[]..[],mxar)
{
	//Block groupings
	return [Imperative]
	{
		bln01 = true;
		blk03 = [];
		ind01 = 0;
		itr01 = 0;
		while (bln01)
		{
			bln02 = List.Count(Blks01(blks,mxar))==List.Count(blks);
			blk01 = Blks02(blks,mxar);
			blk02 = List.RestOfItems(blk01);
			blk03[ind01] = List.FirstItem(blk01);
			bln01 = List.Count(blk02)>0;
			ind01 = ind01 + 1;
			blks = blk02;
		}
		return List.Flatten([blk03,blks],-1);
	}
};

def Blks04 (blks:var[]..[],mxar)
{
	//Merging small isolated blocks
	blks1 = blks;
	blk00 = blks1.Explode();
	cnt01 = List.Count(blk00<1>);
	are01 = Math.Sum(blk00.Area/1000000);
	bln01 = are01<mxar/4;

	blk01 = List.FilterByBoolMask(blks1,bln01);
	blk02 = blk01["out"];
	blk03 = blk01["in"];
	dis01 = blk03<1>.DistanceTo(blk02<2>)==0;
	ind01 = List.IndexOf(dis01<1>,true);
	ind02 = 0;
	blk04 = [Imperative]
	{
		for (i in ind01)
		{
			rep01 = List.Flatten([blk02[i],blk03[ind02]],-1);
			blk02 = List.ReplaceItemAtIndex(blk02,i,rep01);

			ind02 = ind02 + 1;
		}
		return blk02;
	}
	
```

{% endtab %}
{% endtabs %}

{% file src="/files/-MUne8NwsyOL92OHrEqL" %}
Dynamo ver 2.10
{% endfile %}

{% file src="/files/-MUneGswWpCdFEYIvFn2" %}

{% file src="/files/-MUneNhH8yQN\_mMv0sCP" %}

{% file src="/files/-MUneTxJI56OnKDY4DNM" %}

{% file src="/files/-MUneYOKWObZqOkZpQL3" %}


# Area Graph

Subdivide a Rectangle proportionately based on a list of numbers

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-2KC0nUNc_Zwh9mWo%2F-Lg-2VO8OinaFYAu5-HP%2FAreaGraph.gif?alt=media\&token=fe8df1a6-07d6-4f10-9fd4-90132f69927c)

{% file src="/files/-Lg-2Xd3V5AQAV-7MM2f" %}

```d
sq01 = Math.Sqrt(Math.Sum(a));
sq02 = sq01 % Math.Floor(sq01);
sq03 = 1+sq02/Math.Floor(sq01);
sq04 = Rectangle.ByWidthLength(sq03,sq03);
sq05 = sq04.Translate(Vector.YAxis(),0..#Math.Floor(sq01)..sq03);
sq06 = sq05<1>.Translate(Vector.XAxis(),0..#Math.Floor(sq01)..sq03);
sq07 = List.TakeEveryNthItem(sq06,2,1);
sq08 = List.Reverse(List.TakeEveryNthItem(sq06,2,0)<1>);
sq09 = List.Clean(Flatten(List.Transpose({sq07,sq08})),false);
ct01 = Math.Pow(Math.Floor(sq01),2);
ct02 = Math.Round(a/(Math.Sum(a)/ct01));
ct03 = List.ReplaceItemAtIndex(ct02,-1,List.LastItem(ct02)+(ct01-Math.Sum(ct02)));
sq10 = PolySurface.ByJoinedSurfaces(List.Chop(sq09,ct03).Patch());
clr1 = List.Chop(Math.Floor(Math.RemapRange(Math.RandomList(List.Count(sq10)*3),10,255)),List.Count(sq10));
clr2 = Display.ByGeometryColor(sq10,Color.ByARGB(255,clr1[0],clr1[1],clr1[2]));
```


# Array along Curve

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-5tnil1guWrvY4uFk%2F-Lg-5zVpx6k5Zus4m9JN%2FarrayAlongCurve.png?alt=media\&token=447ba91a-c50a-462a-8f15-9a357c6b92bc)

```d
n = 61;

p = Point.ByCoordinates({-1000, -750, -200, -150}, 0, {0, 250, 400, 450});
ns = Surface.ByRevolve(NurbsCurve.ByControlPoints(p, 2),
Point.Origin(), Vector.ZAxis(), 0, 360);
il = ns.GetIsoline(1, {0, 0.075, 0.15, 0.2, 0.35, 0.5, 0.65, 0.8, 1});

il1 = List.DropItems(il,3);
pn1 = il1<1>.PointAtParameter((0..1..#n)<2>);
il2 = List.TakeItems(il,3);
pn2 = il2<1>.PointAtParameter((0..1..#(n*2)-1)<2>);

ln1 = Line.ByStartPointEndPoint(pn1[4],pn1[5]);
pn3 = pn1[0..4];
pn4 = List.ShiftIndices(pn1[1..4]<1>,1);
pn5 = List.ShiftIndices(pn1[1..4]<1>,-1);
ln2 = List.DropItems(Line.ByStartPointEndPoint(pn3,pn4)<1>,1);
ln3 = List.DropItems(Line.ByStartPointEndPoint(pn3,pn5)<1>,-1);
pn6 = List.DropItems(List.Sublists(pn1[0],0..3,3),-1);
pn7 = List.TakeEveryNthItem(List.ShiftIndices(pn2[2],-3),6,1);
ln4 = Line.ByStartPointEndPoint(pn6,pn7);
pn8 = List.TakeEveryNthItem(pn2[1],6,1);
pn9 = List.ShiftIndices(pn8,-1);
ln5 = List.DropItems(Line.ByStartPointEndPoint(pn7,pn8),-1);
ln6 = List.DropItems(Line.ByStartPointEndPoint(pn7,pn9),-1);
p10 = List.TakeEveryNthItem(pn2[0],6,1);
ln7 = Line.ByStartPointEndPoint(pn8,p10);

{il1,ln1,ln2,ln3,ln4,ln5,ln6,ln7};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-5FDjEsrOJAlA3Kbd%2F-Lg-5inNfvkPw_SyUbOn%2FCurvePointsGrouping.png?alt=media\&token=ba27424a-bca9-439f-886f-fa0d3e100910)

{% file src="/files/-Lg-5V1p6xi6y3icST8\_" %}


# Fibbonacci and Factorial

Recursive functions in Design Script

### Pisano Period

{% tabs %}
{% tab title="Patterns" %}
![Random colors based on Pisano Period](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSaRjHcA50YpYFixXc4%2F-MSaUx0ZUiDF3z3Z7Nbd%2FpisanoPeriod.png?alt=media\&token=e2d552e1-b063-49d2-a2a3-d9ee338fe0bc)
{% endtab %}

{% tab title="Colors 1" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSkgLFW4QSQQvB88GbA%2F-MSkhEBxsEuZCd6FXFm0%2FpisanoPeriod_1.png?alt=media\&token=10172058-c964-48a6-a904-eae7c8208f6b)
{% endtab %}

{% tab title="Colors 2" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSkgLFW4QSQQvB88GbA%2F-MSkhPIqGo_NcKDvbku6%2FpisanoPeriod_2.png?alt=media\&token=95a24bd7-bd31-48bc-8235-4e799e6e30fa)
{% endtab %}

{% tab title="Colors 3" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSkgLFW4QSQQvB88GbA%2F-MSkhaMM4IB1B9Hqb8XV%2FpisanoPeriod_3.png?alt=media\&token=0f915d26-940a-4eb8-b200-8e8ff99887a7)
{% endtab %}

{% tab title="Colors 4" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSkgLFW4QSQQvB88GbA%2F-MSkhjHs60lGHKYE2ZzW%2FpisanoPeriod_4.png?alt=media\&token=5faf09cc-a00c-4884-ac31-8570129006f5)
{% endtab %}

{% tab title="Colors 5" %}
![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSkgLFW4QSQQvB88GbA%2F-MSkhpOY0OeBIYsd1ULa%2FpisanoPeriod_5.png?alt=media\&token=7c6f17a3-1725-4a1d-b773-7e33d4ec9d03)
{% endtab %}
{% endtabs %}

![Pisano Period](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSaRjHcA50YpYFixXc4%2F-MSaV2hySw_QIGTJ-kv3%2Ffib_2021-02-03_11-20-20.png?alt=media\&token=e69beb1d-0b7c-4ab4-b60f-74383a8ec45f)

```d
wc = 20;
hc = 12;
wd = 2;
ht = 2;

//Pisano Period
fp1 = fibbonacci(1..wc)%(1..hc)<1>;

//Random Colors
uq1 = List.UniqueItems(List.Flatten(fp1,-1));
rn1 = Math.Round(Math.RemapRange(Math.RandomList(List.Count(uq1)),0,255));
cl1 = Color.ByARGB(255,rn1,List.Shuffle(rn1),List.Reverse(rn1));
cl2 = Dictionary.ByKeysValues(uq1+"",cl1).ValueAtKey(fp1+"");

//Panels
pn1 = Rectangle.ByWidthLength(Plane.ByOriginNormal(Point.ByCoordinates((wd/2..#wc..wd),0,(ht/2..#hc..ht)<2>),Vector.YAxis()),wd,ht).Patch();
pn2 = GeometryColor.ByGeometryColor(pn1,cl2);
```

{% file src="/files/-MSaVbBbGMlfUiP3JKgg" %}
Dynamo Version 2.11
{% endfile %}

### Fibbonacci Series

![Fibbonacci](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MQLX9bwPUvuQ45584yN%2F-MQLY7QturpAupQ5P1Wm%2Ffibbonacci.png?alt=media\&token=dbd991a5-997c-4174-9a28-263745cc5ae3)

```d
def fibbonacci(n)
{
    return [Imperative]
    {
	    if (n == 0)
	    {
	    	return 0;
	    }
	    elseif (n == 1)
	    {
	    	return 1;
	    }
	    else
	    {
	    	return (fibbonacci(n-1) + fibbonacci(n-2));
	    }
	}
};
```

### Factorials

![Factorial](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MQLX9bwPUvuQ45584yN%2F-MQLY4BZ8w89dH66C9hH%2Ffactorial.png?alt=media\&token=63099315-e6ac-4093-bf63-f7626fbf83b0)

```d
def factorial(n)
{
    return [Imperative]
    {
	    if (n <= 1)
	    {
	    	return 1;
	    }
	    else
	    {
	    	return n * factorial(n-1);
	    }
	}
};
```


# Gyroid

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfT5dBcqGKkEfF_GwKq%2F-LfT5mvFcxhIRBdXxJCD%2FGyroid.png?alt=media\&token=08eab108-0525-45a2-983d-77840da9cb71)

{% file src="/files/-LfT5u5EJM1UHDd\_SqaL" %}

```d
l = 10;
o = 3;
n = 3;
p = Point.ByCoordinates([0,l/2,l,l,l,l-o,l,l/2,0,0,0,o,0,l/2,l/2,l/2,l-o,o,l-o,o],[l,l,l,l-o,l,l/2,0,0,0,o,0,l/2,l,l/2,l-o,o,l-o,o,l/2,l/2],[0,o,0,l/2,l,l,l,l-o,l,l/2,0,0,0,l/2,o,l-o,l/2,l/2,l-o,o]);
a = Arc.ByThreePoints(p[[0..10..2]],p[[1..11..2]],p[[2..12..2]]).SplitByParameter(0.5)[0];
b = Arc.ByThreePoints(p[[1,13,3,13,5,13]],p[14..19],p[[13,7,13,9,13,11]]);
m1 = PolySurface.ByJoinedSurfaces(PolyCurve.ByJoinedCurves([[a[5][1],a[0][0],b[0],b[5]],[a[0][1],a[1][0],b[2],b[0]],[a[1][1],a[2][0],b[4],b[2]],[a[2][1],a[3][0],b[4],b[1]],[a[3][1],a[4][0],b[3],b[1]],[a[4][1],a[5][0],b[5],b[3]]]).Patch());
m2 = PolySurface.ByJoinedSurfaces(List.Flatten([m1,m1.Rotate(Point.Origin(),Vector.ZAxis(),-180).Translate(l,2*l,0)],-1));
m3 = PolySurface.ByJoinedSurfaces(List.Flatten([m2,m2.Mirror(Plane.XY()).Mirror(Plane.YZ()).Translate(0,0,l)],-1));
m4 = PolySurface.ByJoinedSurfaces(List.Flatten([m3,m3.Mirror(Plane.XY()).Rotate(Point.Origin(),Vector.ZAxis(),180).Translate(0,2*l,2*l)],-1));
m5 = PolySurface.ByJoinedSurfaces(List.Flatten(m4.Translate((0..#n..2*l)<1>,(0..#n..2*l)<2>,(0..#n..2*l)<3>),-1));
```

#### Gyroid - Equation

```d
[Imperative]
{
	n = 360;
	i = 0.02;
	px = [];
	py = [];
	pz = [];
	x = 0;
	c = 0;
	while (x<n)
	{
		y = 0;
		while(y<n)
		{
			z = 0;
			while(z<n)
			{
				b = (Math.Sin(x)*Math.Cos(y))
				+ (Math.Sin(y)*Math.Cos(z))
				+ (Math.Sin(z)*Math.Cos(x));
				if (Math.Round(b,3) == 0)
				{
					px[c] = x;
					py[c] = y;
					pz[c] = z;
					c = c + 1;
				}
				z = z + i;
			}
			y = y + i;
		}
		x = x + i;
	}
	return = Point.ByCoordinates(px,py,pz);
};
```

{% file src="/files/-LfT4XRQl3\_BIsjWi-M3" %}


# Hexagonal Pattern From Image

Scaled triangles corresponding to pixel brightness within each hexagon that makes up a hexagonal grid stretching across the extents of an image

![x count = 20, y count = 20](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LyUvV-CGNM1iWXGUSCQ%2F-LyUxp08Z4Ay2FeG_d1M%2FimageHex_2020-01-13_08-54-16.png?alt=media\&token=7a58bf4e-3ee8-493f-90cb-179d0c0bf08b)

```d
img = Image.ReadFromFile(fil);

//Image Dimensions
w = Image.Dimensions(img)["width"];
h = Image.Dimensions(img)["height"];

//Surface corresponding to image proportions
pnt1 = Point.ByCoordinates(List.RestOfItems(0..w)<1>,List.RestOfItems(0..h)<2>);
srf = NurbsSurface.ByPoints(pnt1, 3, 3);

//Increase for more detail
xc = 10;
yc = 10;

//Hexagon Points Grid
s = 10;
a = s/(2*Math.Tan(30));
p1 = Point.ByCoordinates((0..#xc..s*3)<1>,(0..#yc..a*2)<2>);
p2 = List.Flatten(p1<1>.Translate([0,s*1.5]<2>,[0,a]<2>,0),1);
p3 = Polygon.RegularPolygon(Circle.ByCenterPointRadius(p2,s),6);

p4 = List.Flatten(p3,-1).Points;
p5 = List.Sublists(List.AddItemToEnd(List.FirstItem(p4<1>)<1>,p4<1>)<1>,0..1,1);
p6 = List.AddItemToFront(List.Flatten(p2,-1)<1>,List.DropItems(p5<1>,-1)<1><2>);

//Triangles
//p7 = Polygon.ByPoints(p6);
c1 = Point.ByCoordinates(Math.Sum(p6.X)/3,Math.Sum(p6.Y)/3);

//Triangle UV
u1 = UV.ByCoordinates((p6.X-List.MinimumItem(List.Flatten(p6,-1).X))/List.MaximumItem(List.Flatten(p6,-1).X),
(p6.Y-List.MinimumItem(List.Flatten(p6,-1).Y))/List.MaximumItem(List.Flatten(p6,-1).Y));
//Triangle Centroid
u2 = UV.ByCoordinates((c1.X-List.MinimumItem(List.Flatten(c1,-1).X))/List.MaximumItem(List.Flatten(c1,-1).X),
(c1.Y-List.MinimumItem(List.Flatten(c1,-1).Y))/List.MaximumItem(List.Flatten(c1,-1).Y));

//Minimum and Maximum parameters
minX = List.MinimumItem(List.Flatten(p6.X,-1));
maxX = List.MaximumItem(List.Flatten(p6.X,-1));
minY = List.MinimumItem(List.Flatten(p6.Y,-1));
maxY = List.MaximumItem(List.Flatten(p6.Y,-1));

//b1 + (s-a1)*(b2-b1)/(a2-a1)
//Triangle UV
uv1 = UV.ByCoordinates((p6.X-minX)/(maxX-minX),(p6.Y-minY)/(maxY-minY));
//Triangle Centroid UV
uv2 = UV.ByCoordinates((c1.X-minX)/(maxX-minX),(c1.Y-minY)/(maxY-minY));

//Image Pixels
pxl1 = List.Flatten(List.Reverse(Image.Pixels(img, w, h)),-1);
prm1 = List.Flatten(UV.ByCoordinates((0..1..#h)<1>, (0..1..#w)<2>),-1);
clr1 = (ColorRange.ByColorsAndParameters(pxl1, prm1)).GetColorAtParameter(uv2);

//Triangles on Surface
cnt1 = srf.PointAtParameter(uv2.U,uv2.V);
thk1 = 0.25;
tri1 = Surface.ByPerimeterPoints(srf.PointAtParameter(uv1.U,uv1.V)).Thicken(thk1);
pln1 = Plane.ByOriginNormal(cnt1,srf.NormalAtPoint(cnt1));

tri2 = tri1.Scale(pln1,(1-Color.Brightness(clr1))+0.00001,(1-Color.Brightness(clr1))+0.00001,1);
```

![x-count = 10, y count =10](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LyUvV-CGNM1iWXGUSCQ%2F-LyUxWSOQk-xH-0V6CqB%2FimageHex_2020-01-13_10-50-32.png?alt=media\&token=fd901f4b-f361-4f6b-b147-860212c9e04d)


# Hexagonal Grid

```d
//Hexagon Points Grid
s = 1;
a = s/(2*Math.Tan(30));
p1 = Point.ByCoordinates((0..#15..s*3)<1>,(0..#25..a*2)<2>);
p2 = List.Flatten(p1<1>.Translate([0,s*1.5]<2>,[0,a]<2>,0),1);
p3 = Polygon.RegularPolygon(Circle.ByCenterPointRadius(p2,s),6).Points;
d1 = (15*s*3)/((Math.Pow(p3.DistanceTo(Point.ByCoordinates(15*s*3/2,25*a*2/2)),0.75))+0.2);
p4 = Polygon.ByPoints(p3.Translate(Vector.ZAxis(),-d1+35));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LxksFSk2EX-dlrNFpWC%2F-LxksZqUT6nS-5lmiITF%2Fninebridges.png?alt=media\&token=f44fe8eb-1431-4183-a84f-9429806eb3b6)

```d
//Hexagon Points Grid
s = 10;
a = s/(2*Math.Tan(30));
p1 = Point.ByCoordinates((0..#15..s*3)<1>,(0..#25..a*2)<2>);
p2 = List.Flatten(p1<1>.Translate([0,s*1.5]<2>,[0,a]<2>,0),1);
p3 = Polygon.RegularPolygon(Circle.ByCenterPointRadius(p2,s),6);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lf5hv81tMZEN3x754kI%2F-Lf5hyBOhCh_k10HXdJz%2FhexGrd-1.png?alt=media\&token=1869341b-cca9-4d5d-b9a7-5875e63c3f8d)

```d
p4 = p3.Points;

//Attractor 1
v1 = Vector.ByTwoPoints(p3,a1);
v2 = v1.Scale(2/Math.Pow(v1.Length,0.25));
p5 = p4.Translate(v2);

//Attractor 2
v3 = Vector.ByTwoPoints(p4,a2);
v4 = v3.Scale(2/Math.Pow(v3.Length,0.25));
p6 = p5.Translate(v4);
```

#### Hexagonal Grid on Surface

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQ8JuDp5wtD1GEazC0%2F-LfQ8_dw_n8GBVHes3Oo%2FSurface_Hexagon_Panelation-1.png?alt=media\&token=050a2ffa-ddbd-465e-bad1-e12010cd4943)

```d
//Square Dimensions
wdt1 = 5000;

uDv1 = 15;
vDv1 = 20;

//Surface
srf1 = Surface.ByPatch(Rectangle.ByWidthLength(wdt1,wdt1));
rem1 = Math.DivRem(uDv1,3);
uDv2 = rem1==2?uDv1+1:uDv1+2;
uDv3 = rem1==3?uDv1:uDv2;
pt01 = srf1.PointAtParameter((0..1..#uDv3)<1>,(0..1..#vDv1)<2>);
pt02 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,-2),2,1);
pt03 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,-1),2,1);
pt04 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,-3),2,0);
pt05 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,0),2,0);

//Polygons
pt11 = [List.DropItems(pt02,-1),
List.DropItems(pt03,-1),pt05,
List.DropItems(pt03,1),
List.DropItems(pt02,1),pt04];
pt12 = List.Transpose(List.Transpose(pt11)<1>);

pt13 = [List.DropItems(List.DropItems(pt05<1>,-1),-1),
List.DropItems(List.DropItems(pt04<1>,1),-1),
List.DropItems(List.DropItems(List.DropItems(pt02<1>,1),1),-1),
List.DropItems(List.DropItems(pt04<1>,1),1),
List.DropItems(List.DropItems(pt05<1>,-1),1),
List.DropItems(List.DropItems(List.DropItems(pt03<1>,-1),1),-1)];
pt14 = List.Transpose(List.Transpose(pt13)<1>);

pg11 = Polygon.ByPoints([pt12,pt14]);];
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQBxtouC92Lqiq9FtA%2F-LfQC4P6EQ_NDneD1Kox%2FSurface_Hexagon_Panelation-2.png?alt=media\&token=20743315-3da4-4b61-a0ef-ea476fe37c48)

```d
//Surface
srf1 = Surface.ByRevolve(NurbsCurve.ByPoints(Point.ByCoordinates
([20,18,18,22,22],0,[0,2,5,10,15])),Point.Origin(),Vector.ZAxis(),0,-180);

uDv1 = 25;
vDv1 = 52;
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-3XbKxiPDDGlC7LT7%2F-Lg-3ehijY5GkBEj5eWA%2Fhexagon.png?alt=media\&token=11a0c27f-aea4-4375-ab7e-d9e569b38c79)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-3XbKxiPDDGlC7LT7%2F-Lg-4C_t47ytJMIyvykK%2FhexagonOnSurface.png?alt=media\&token=040e17e4-8556-443c-8a35-c1cf2f8cba8c)

{% file src="/files/-Lg-4F58O66gMcRJc2UO" %}


# Koch Star

Pattern based on Koch curve

![T-Spine visualization of Koch curve structure](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Ml8OgfMNKjTIa58Qnqb%2F-Ml8OvtgRWDXhwMFx-1N%2Fkoch_2021-10-04_08-56-34.png?alt=media\&token=9a78cac8-494e-4cb1-be43-456fb45047c0)

```
def k1 (p:var[]..[])
{
	v1 = Vector.ByTwoPoints(p[0],p[1]).Normalized();
	d1 = p[0].DistanceTo(p[1]);
	p1 = p[0].Translate(v1,d1/3);
	v2 = v1.Rotate(Vector.ZAxis(),60);
	p2 = p1.Translate(v2,d1/3);
	p3 = p1.Translate(v1,d1/3);
	return [p[0],p1,p2,p3,p[1]];
};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MlA7MxcugdJlBYcyfTy%2F-MlA9LDroo3GpXvf3Ahq%2Fkoch2_2021-10-04_05-23-49.png?alt=media\&token=c8c2f850-9536-48ea-ab14-d1b93bf5652a)

With Loops

```

def k2 (pts:var[]..[])
{
	p1 = List.DropItems(List.Sublists(pts,0..1,1),-1);
	p2 = k1(p1<1>);
	p3 = Point.PruneDuplicates(List.Flatten(p2,-1),0.1);
	return List.AddItemToEnd(p3[0],p3);
};

def k3 (pt:var[]..[],it:int)
{
	a = [Imperative]
	{
		c = 0;
		b = [];
		while (c < it)
		{
			b = k2(pt);
			pt = b;
			c = c + 1;
		}
		return b;
	}
	return a;
};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MlA7MxcugdJlBYcyfTy%2F-MlA9QuB3m0dnPiwNZVA%2Fkoch2_2021-10-04_05-21-10.png?alt=media\&token=9c5f709e-6069-4abd-a5ff-d34b85f87e2e)

With Recursion

```

def k2(pts:var[]..[],n:int[]..[])
{
	a = [Imperative]
	{
		if (List.Count(pts)>=Math.Pow(5,n))
			return pts;
		else
		{
			b = [Associative]
			{
				p1 = List.DropItems(List.Sublists(pts,0..1,1),-1);
				p2 = k1(p1<1>);
				p3 = List.Flatten(p2,-1);
				return p3;
			}
			return Point.PruneDuplicates(k2(b,n),0.1);
		}
	}
	b = List.Clean(List.Flatten(a,-1),false);
	return List.AddItemToEnd(List.FirstItem(b),b);
};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MlA7MxcugdJlBYcyfTy%2F-MlA9dNoDk0amjQ3LurK%2Fkoch2_2021-10-04_05-19-54.png?alt=media\&token=b1120bb8-b332-489a-9e0c-3df3ea07b944)

Visualization with T-Splines

```
// T Spline Visualization
p001 = List.Transpose(Circle.ByCenterPointRadius(Point.Origin(),
[50,35,25,5])<1>.PointAtParameter((1..0..#4)<2>));
p002 = k2(p001<1>,2).Translate(Vector.ZAxis(),[0,10,15,60]);
pc01 = PolyCurve.ByPoints(List.Transpose(p002));
pc02 = PolyCurve.ByPoints(pc01.PointAtParameter((0..1..#10)<1>));
ts01 = TSplineSurface.BuildPipes(List.Flatten(pc01.Explode(),-1),
1.5,0.1,3,true,false,0,0,1,0.3,1,1,true);
ts02 = TSplineSurface.BuildPipes(pc02.Explode(),2..0.2..#10,
2..0.2..#10,3,true,false,0,0,1,0.3,1,1,true);
ts03 = TSplineSurface.ByCombinedTSplineSurfaces
(List.Flatten([ts01,ts02],-1)).Translate(150,0,0);
```

{% file src="/files/5oseCdF6qavIFO2yvrdb" %}
STL file
{% endfile %}


# Mandelbrot Set

&#x20;Mathematically, the Mandelbrot set is defined on the plane of complex numbers

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MkpL1smXWXMM3PSyo-r%2F-MkpLB9QIJ_VlMxyFJVu%2Fmandelbrot_2021-09-30_11-09-13.png?alt=media\&token=62bfd7e6-6a94-49f6-b8f6-654c311f7a4a)

```d

//Function
def mandelbrot(wd,ht,mx)
{
	return [Imperative]
	{
		it = [];
		for (rw in 0..ht-1)
		{
		    for (cl in 0..wd-1)
		    {
		        rl = (cl - wd/2.0)*4.0/wd;
		        im = (rw - ht/2.0)*4.0/wd;
		        x = 0;
		        y = 0;
		        n = 0;
		        while (x*x+y*y <= 4 && n < mx)
		        {
		            x1 = x*x - y*y + rl;
		            y = 2*x*y + im;
		            x = x1;
		            n = n + 1;
		        }
		        it[cl][rw] = n;
		    }
		}
		return it;
	}
};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MRzePv7Gy9xnRBxJd6O%2F-MRzni0nVhi-baaYTSPO%2Fmandelbrot_2021-01-26_11-17-11.png?alt=media\&token=12e04818-fcbe-4fa9-b34d-10ff40db1df7)

```d
wd = 200;
hg = 200;
m = mandelbrot(wd,hg,50);

//Visualization
q = List.Reverse(List.Sort(List.UniqueItems(List.Flatten(m,-1))));
r = List.DropItems(Math.Round(Math.RemapRange(q,10,250)),-1);
d = Dictionary.ByKeysValues(q+"", List.Flatten([Color.ByARGB
(250,175,230,125),Color.ByARGB(List.Reverse(r),List.ShiftIndices
(r,100),List.ShiftIndices(r,-13),List.Reverse(r))],-1));
c = Image.FromPixels(List.Transpose(d.ValueAtKey(m+"")));

//Surface
pt1 = Point.ByCoordinates((-wd/2..wd/2..#wd)<1>,(-hg/2..hg/2..#hg)<2>);
el1 = List.Chop(Math.RemapRange(List.Flatten(m,-1),0,hg/10),hg);
sr1 = NurbsSurface.ByControlPoints(pt1.Translate(Vector.ZAxis(),el1));
sr2 = GeometryColor.BySurfaceColors(sr1,d.ValueAtKey(m+""));
```

![Maximum Iterations: 10](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MRzRImSN0RB_Tk_WxlF%2F-MRze8LaPE2HfUHHoAh4%2Fmandelbrot.png?alt=media\&token=78858b8b-48cf-480d-b28f-160e9cfbe406)

![Maximum Iterations: 30](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MRzRImSN0RB_Tk_WxlF%2F-MRzdSKTWvE7BRSwRAYx%2Fmandelbrot.png?alt=media\&token=db4b6929-8e92-498b-b6e1-d2952a675b91)

> Joni "Let’s draw the Mandelbrot set!", November 17, 2013 <[https://jonisalonen.com/2013/lets-draw-the-mandelbrot-set/>](https://jonisalonen.com/2013/lets-draw-the-mandelbrot-set/>)  January  26, 2021


# Pattern

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQUJp_yIkmTIvwEt06%2F-LfQUgHRTw3C0JGNsq_E%2FPattern1.png?alt=media\&token=e6d9b2d6-873f-423b-aa08-3c1ef4ec61ec)

```d
//Length of smallest side
side = 1;

//Number of modules (X)
nx = 8;

//Number of modules (Y)
ny = 8;

//The module is a square with an inscribed regular Octagon and another smaller Octagon within
//The dimension of the square side is equal to twice the Apothem of the Larger Octagon
//The length of the large Octagon side is twice the length of the smaller Octagon

//The Apothem of the larger Octagon is calculated
a = side/(2*Math.Tan(180/8));

//The circumradius of the large Octagon
r = a/(Math.Cos(180/8));

//Points for one module
//Corner Points of Bounding Square
pnt01 = Point.ByCoordinates({2*a,-2*a,-2*a,2*a},{2*a,2*a,-2*a,-2*a});
//Midpoints of large Octagon sides
pnt02 = (Point.Origin()).Translate(Vector.XAxis(),2*a).Rotate(Point.Origin(),Vector.ZAxis(),45..360..45);
//Corner Points of Large Octagon
pnt03 = (Point.Origin()).Translate(Vector.XAxis(),2*r).Rotate(Point.Origin(),Vector.ZAxis(),22.5..337.5..45);
//Corner Points of Small Octagon
pnt04 = (Point.Origin()).Translate(Vector.XAxis(),r).Rotate(Point.Origin(),Vector.ZAxis(),22.5..337.5..45);

//Square Corner Triangulation
tri11 = Transpose({List.TakeEveryNthItem(pnt03,2,1),List.TakeEveryNthItem(pnt02,2,1),pnt01});
tri12 = Transpose({List.TakeEveryNthItem(pnt02,2,1),pnt01,List.TakeEveryNthItem(pnt03,2,0)});

//Large Octagon Triangulation
tri13 = Transpose({pnt02,pnt03,pnt04});
tri14 = Transpose({List.ShiftIndices(pnt03,-1),List.ShiftIndices(pnt02,-1),List.ShiftIndices(pnt04,-1)});
tri15 = Transpose({pnt02,pnt04,List.ShiftIndices(pnt04,-1)});
tri16 = Transpose({List.ShiftIndices(pnt03,-1),List.ShiftIndices(pnt02,0),List.ShiftIndices(pnt04,-1)});

//Small Octagon Triangulation
tri17 = List.AddItemToFront(Point.Origin(),Transpose({pnt04,List.ShiftIndices(pnt04,1)})<1>);

//Three point groups for module
triPt = List.Flatten({tri11,tri12,tri13,tri14,tri15,tri16,tri17},1);

//Grid
pnts1 = Point.ByCoordinates((2*a..#nx..4*a)<1>,(2*a..#ny..4*a)<2>);

//Place instances of the points module at grid points.
cdSy1 = CoordinateSystem.ByOrigin(pnts1);
pat01 = triPt.Transform(cdSy1<1><2>);

```


# Pattern

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M293V5BKB_M3S_NY0ky%2F-M293hS0Qd3mIPzURARN%2Fpattern_2020-03-11_07-59-56.png?alt=media\&token=9eaaba0e-7710-4272-acea-65d663df3efe)

```d
//Parameters
w = 50;
l = 50;
nw = 10;
nl = 10;

h = (w/nw)*0.25;
t = 10;

//Base Surface
srf = Rectangle.ByWidthLength(w,l).Patch();

c1 = NurbsCurve.ByPoints(Point.ByCoordinates(-w/2,[-l/2,0,l/2],[0,t/3,0]));
c2 = NurbsCurve.ByPoints(Point.ByCoordinates(w/2,[-l/4,0,l/4],[t*3,t/2,0]));
//srf = Surface.ByLoft([c2,c1]);

//Points Grid
p00 = srf.PointAtParameter((0..1..#(nw*3)+1)<1>,(0..1..#(nl*3)+1)<2>);
n00 = srf.NormalAtParameter((0..1..#(nw*3)+1)<1>,(0..1..#(nl*3)+1)<2>);

//Quad 01
p10 = List.TakeEveryNthItem(p00,6,1);
n11 = List.TakeEveryNthItem(n00,6,1);
p11 = p10.Translate(n11,h);
p12 = List.TakeEveryNthItem(p00,6,2);
p13 = List.TakeEveryNthItem(p00,6,3);
p14 = List.TakeEveryNthItem(p11<1>,6,2);
p15 = List.TakeEveryNthItem(p11<1>,6,4);
p16 = List.TakeEveryNthItem(p13<1>,6,3);
p17 = List.TakeEveryNthItem(p12<1>,6,2);
p18 = List.Clean(List.Transpose(List.Transpose([p14,p15,p16,p17])<1>),false);
pg1 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p18,List.Count(p18<1><2>)>3)["in"]);

//Quad 02
p20 = List.TakeEveryNthItem(p00,6,4);
n21 = List.TakeEveryNthItem(n00,6,4);
p21 = p20.Translate(n21,h);
p24 = List.TakeEveryNthItem(p21<1>,6,3);
p25 = List.TakeEveryNthItem(p21<1>,6,1);
p28 = List.Clean(List.Transpose(List.Transpose([p17,p16,p24,p25])<1>),false);
pg2 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p28,List.Count(p28<1><2>)>3)["in"]);

//Quad 03
p31 = List.TakeEveryNthItem(p00,6,5);
p32 = List.TakeEveryNthItem(p00,6,6);
p36 = List.TakeEveryNthItem(p32<1>,6,2);
p37 = List.TakeEveryNthItem(p31<1>,6,3);
p38 = List.Clean(List.Transpose(List.Transpose([p25,p24,p37,p36])<1>),false);
pg3 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p38,List.Count(p38<1><2>)>3)["in"]);

//Quad 04
p41 = List.DropItems(p14,1);
p42 = List.DropItems(p15,1);
p48 = List.Clean(List.Transpose(List.Transpose([p36,p37,p42,p41])<1>),false);
pg4 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p48,List.Count(p48<1><2>)>3)["in"]);

//Tri 01
p57 = List.TakeEveryNthItem(p20<1>,6,3);
p58 = List.Clean(List.Transpose(List.Transpose([p16,p24,p57])<1>),false);
pg5 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p58,List.Count(p58<1><2>)>2)["in"]);

//Tri 02
p68 = List.Clean(List.Transpose(List.Transpose([p37,p24,p57])<1>),false);
pg6 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p68,List.Count(p68<1><2>)>2)["in"]);

//Tri 03
p77 = List.TakeEveryNthItem(p10<1>,6,2);
p78 = List.Clean(List.Transpose(List.Transpose([p77,p14,p17])<1>),false);
pg7 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p78,List.Count(p78<1><2>)>2)["in"]);

//Tri 04
p87 = List.DropItems(List.TakeEveryNthItem(p10<1>,6,2),1);
p88 = List.Clean(List.Transpose(List.Transpose([p36,p41,p87])<1>),false);
pg8 = Surface.ByPerimeterPoints(List.FilterByBoolMask(p88,List.Count(p88<1><2>)>2)["in"]);

//Quad 05
q14 = List.TakeEveryNthItem(p11<1>,6,0)<1>;
q15 = List.TakeEveryNthItem(p12<1>,6,6)<1>;
q16 = List.TakeEveryNthItem(p13<1>,6,5);
q18 = List.Clean(List.Transpose(List.Transpose([p15,q14,q15,q16])<1>),false);
qg1 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q18,List.Count(q18<1><2>)>3)["in"]);

//Quad 06
q24 = List.TakeEveryNthItem(p21<1>,6,5);
q25 = List.DropItems(p25<1>,1);
q28 = List.Clean(List.Transpose(List.Transpose([q24,q16,q15,q25])<1>),false);
qg2 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q28,List.Count(q28<1><2>)>3)["in"]);

//Quad 07
q34 = List.TakeEveryNthItem(p32<1>,6,6);
q35 = List.TakeEveryNthItem(p31<1>,6,5);
q38 = List.Clean(List.Transpose(List.Transpose([q34,q35,q24,q25])<1>),false);
qg3 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q38,List.Count(q38<1><2>)>3)["in"]);

//Quad 08
q44 = List.DropItems(p15,1);
q45 = List.DropItems(q14,1);
q48 = List.Clean(List.Transpose(List.Transpose([q44,q35,q34,q45])<1>),false);
qg4 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q48,List.Count(q48<1><2>)>3)["in"]);

//Tri 05
q54 = List.TakeEveryNthItem(p20<1>,6,5);
q58 = List.Clean(List.Transpose(List.Transpose([q16,q24,q54])<1>),false);
qg5 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q58,List.Count(q58<1><2>)>2)["in"]);

//Tri 06
q68 = List.Clean(List.Transpose(List.Transpose([q54,q24,q35])<1>),false);
qg6 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q68,List.Count(q68<1><2>)>2)["in"]);

//Tri 07
q74 = List.TakeEveryNthItem(p10<1>,6,0)<1>;
q78 = List.Clean(List.Transpose(List.Transpose([q14,q15,q74])<1>),false);
qg7 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q78,List.Count(q78<1><2>)>2)["in"]);

//Tri 08
q84 = List.DropItems(q14,1);
q85 = List.DropItems(q15,1);
q88 = List.Clean(List.Transpose(List.Transpose([q34,q84,q85])<1>),false);
qg8 = Surface.ByPerimeterPoints(List.FilterByBoolMask(q88,List.Count(q88<1><2>)>2)["in"]);

//Quad 09
r11 = List.TakeEveryNthItem(p21<1>,6,4);
r12 = List.TakeEveryNthItem(p20<1>,6,3);
r18 = List.Clean(List.Transpose(List.Transpose([p15,r11,r12,p16])<1>),false);
rg1 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r18,List.Count(r18<1><2>)>3)["in"]);

//Quad 10
r28 = List.Clean(List.Transpose(List.Transpose([p42,p37,r12,r11])<1>),false);
rg2 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r28,List.Count(r28<1><2>)>3)["in"]);

//Quad 11
r38 = List.Clean(List.Transpose(List.Transpose([r11,p15,q16,q54])<1>),false);
rg3 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r38,List.Count(r38<1><2>)>3)["in"]);

//Quad 12
r48 = List.Clean(List.Transpose(List.Transpose([r11,q54,q35,p42])<1>),false);
rg4 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r48,List.Count(r48<1><2>)>3)["in"]);

//Quad 13
r51 = List.TakeEveryNthItem(p11<1>,6,1);
r58 = List.Clean(List.Transpose(List.Transpose([r51,p77,p17,p25])<1>),false);
rg5 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r58,List.Count(r58<1><2>)>3)["in"]);

//Quad 14
r61 = List.DropItems(p77,1);
r62 = List.DropItems(r51,1);
r68 = List.Clean(List.Transpose(List.Transpose([p25,p36,r61,r62])<1>),false);
rg6 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r68,List.Count(r68<1><2>)>3)["in"]);

//Quad 15
r71 = List.DropItems(r51<1>,1);
r78 = List.Clean(List.Transpose(List.Transpose([r71,q25,q15,q74])<1>),false);
rg7 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r78,List.Count(r78<1><2>)>3)["in"]);

//Quad 16
r81 = List.DropItems(List.DropItems(r51,1)<1>,1);
r82 = List.DropItems(q74,1);
r88 = List.Clean(List.Transpose(List.Transpose([q25,r81,r82,q34])<1>),false);
rg8 = Surface.ByPerimeterPoints(List.FilterByBoolMask(r88,List.Count(r88<1><2>)>3)["in"]);

pn1 = List.Flatten([pg1,pg2,pg3,pg4,pg5,pg6,pg7,pg8,qg1,qg2,qg3,qg4,qg5,qg6,qg7,qg8,rg1,rg2,rg3,rg4,rg5,rg6,rg7,rg8],-1);

//Punctures
b11 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,2)<1>,6,2);
b12 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,3)<1>,6,3);
b13 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,2)<1>,6,0);
b14 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,3)<1>,6,5);
b21 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,5)<1>,6,3);
b22 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,6)<1>,6,2);
b23 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,5)<1>,6,5);
b24 = List.TakeEveryNthItem(List.TakeEveryNthItem(p00,6,6)<1>,6,0);
sp1 = List.Flatten([b11,b13,b21,b23],-1);
ep1 = List.Flatten([b12,b14,b22,b24],-1);

bl1 = Line.ByStartPointEndPoint(sp1,ep1).TrimByParameter(0.2,0.8);
tk1 = Math.Average(bl1.Length);
d01 = bl1.DistanceTo(srf.PointAtParameter(0.5,0.5));
tk2 = Math.RemapRange(d01,tk1/10,tk1/3);
dr1 = srf.NormalAtPoint(bl1.PointAtParameter(0.5));
sl1 = Solid.ByUnion(PolyCurve.ByThickeningCurve(bl1,tk2,dr1).Patch().Thicken(tk2));

pn2 = List.Flatten(pn1.SubtractFrom(sl1),-1);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M293V5BKB_M3S_NY0ky%2F-M2940iIoXx83QkEl94U%2Fpattern_2020-03-11_08-05-15.png?alt=media\&token=23bc59cf-91f5-448c-b5bf-cff02bc6254e)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M293V5BKB_M3S_NY0ky%2F-M293viyVnxJ5ARCVaD9%2Fpattern_2020-03-11_08-02-13.png?alt=media\&token=baeeeef3-efdc-45e6-a825-caf01fd7da42)


# Pattern

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLcLnFju9IDYZuh58y%2F-LhLcjOqSxQ-lOm1D4Pi%2Fpattern-1.jpg?alt=media\&token=d4906df8-622e-467f-b239-8b0ec9a055e1)

{% file src="/files/-LhLcrm9lr0NM\_M5ewC8" %}

```d
c1 = NurbsCurve.ByPoints(Autodesk.Point.ByCoordinates
([0,0.1,0.5,0.9,1],[0.1,0.125,0.5,0.74,0.75]));
c2 = Arc.ByCenterPointStartPointEndPoint(Autodesk.Point.ByCoordinates(1,0),
Autodesk.Point.ByCoordinates(1,0,-0.75),Autodesk.Point.ByCoordinates(1,0.75));
c3 = Arc.ByCenterPointStartPointEndPoint(Autodesk.Point.ByCoordinates(0,0.75),
Autodesk.Point.ByCoordinates(0,0.1),Autodesk.Point.ByCoordinates(0,0.75,-0.75));
[c2,c3];
```

```d
surface1 = Surface.BySweep(c1, t3);
plane1 = Plane.XZ();
geometry1 = Geometry.Mirror(surface1, plane1);
t4 = [surface1, geometry1];
plane2 = Plane.YZ();
geometry2 = Geometry.Mirror(t4, plane2);
t5 = [t4, geometry2];
t6 = List.Flatten(t5, -1);
polySurface1 = PolySurface.ByJoinedSurfaces(t6);
t1 = (0..#10..2);
t2 = (0..#10..1.5);
geometry3 = Geometry.Translate(polySurface1<1>, t1<2>, t2<3>, 0);
```


# Phyllotaxis

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh8laziipL6pQjdlbIT%2F-Lh8nq_8hDB2zIA2fd0e%2FphyllotacticGherkin.png?alt=media\&token=05c9251e-b17b-4d0d-8800-1280f8633b21)

<http://algorithmicbotany.org/papers/abop/abop-ch4.pdf>

```d
//Gherkin Surface
sr01 = Surface.ByLoft(Circle.ByCenterPointRadius
(Point.ByCoordinates(0,0,[0,85,168,173,175]),[25,28,11,7,3]));

//Density
n = 1000;

//Alpha
a = 137.5;

//Phyllotactic Points
pt01 = Point.ByCylindricalCoordinates(CoordinateSystem.Identity(),
(0..n)*a,0, Math.Sqrt(0..n));

//Determining Point Parameters to map to surface
pg01 = Polygon.RegularPolygon(Circle.ByCenterPointRadius(Point.Origin(),
Math.Sqrt(n)),4).Rotate(Point.Origin(),Vector.ZAxis(),45);

pr01 = pg01.Patch().UVParameterAtPoint(List.FilterByBoolMask
(pt01,pg01.ContainmentTest(pt01))["in"]);

pt02 = sr01.PointAtParameter(pr01.U,pr01.V);

sp01 = [sr01,Sphere.ByCenterPointRadius(pt02,5)];
```


# Random Strip Widths

Planks are in 3 different widths which has to be randomly divided over the length of the wall: 145 mm - 50%, 95 mm - 30%, 46 mm - 20%  and the gap between planks is 10 mm.

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-90GzMnl0PFe-p_Up%2F-Lg-9CZsLEl1BeA5Ur_A%2FrandomStripWidths.png?alt=media\&token=129fc3b9-149c-4b51-a287-a2c51b69fc72)

```d
//Facade dimensions
l = 2;
h = 2;

//Panel widths
pw1 = 0.145;
pw2 = 0.095;
pw3 = 0.046;
spc = 0.010;

pw11 = pw1+spc;
pw21 = pw2+spc;
pw31 = pw3+spc;

//Panel count percentage
pwn1 = Math.Floor((0.5*l)/pw11);
pwn2 = Math.Floor((0.3*l)/pw21);
pwn3 = Math.Floor((0.2*l)/pw31);

pw12 = List.Cycle(pw11,pwn1);
pw22 = List.Cycle(pw21,pwn2);
pw32 = List.Cycle(pw31,pwn3);

a = List.Shuffle(Flatten({pw12,pw22,pw32}));
b = Math.Sum(List.TakeItems(a,1..List.Count(a))<1>);
c = b - a;
d = b - spc;

bp = Point.Origin();
dr = Vector.XAxis();

st = bp.Translate(dr,c);
en = bp.Translate(dr,d);
ln = Line.ByStartPointEndPoint(st,en);
sr = ln.Extrude(Vector.ZAxis(),h);
```


# Skewed Surface

Pattern

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLzikCGGSdb7F7PjuN%2F-LhM0JbHpRDhwstzvzcC%2FSkewedSurfacePattern.png?alt=media\&token=a3395cc8-69e6-48c3-a8f0-df52d307b0d6)


# Staggered Checkerboard

Pattern of Small and Large Squares

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfQWY_J9NidhVDevh9l%2F-LfQWenj7sSCK_Ptbaz-%2FPattern2.png?alt=media\&token=d008c566-92b7-4aff-9f81-f193424a80a0)

```d
bdr = Rectangle.ByWidthLength(50,50).Translate(25,25,0);
s1 = 5;
s2 = 1;
n1 = 12;
n2 = 12;

//Boundary
bdr1 = bdr.Offset(s1/2.1).Length>bdr.Offset(-s1/2.1).Length?bdr.Offset(s1/2.1):bdr.Offset(-s1/2.1);
bdr11 = Polygon.ByPoints(bdr1.Explode().StartPoint);

//Large Squares
pnt11 = Point.ByCoordinates((0..#n1*2..s1),(s2..n1*2));
pnt12 = pnt11.Translate(s1/2,s1/2,0);
pnt13 = pnt12<1>.Translate(0..(-s2*n2),0..(s1-s2)*n2..s1,0);
pnt14 = pnt12<1>.Translate(s2..(s2*n2),-s1..(s1-s2)*-n2..-s1,0);
pnt15 = List.Flatten([pnt13,pnt14],-1);
msk15 = bdr11.ContainmentTest(pnt15);
pnt16 = List.FilterByBoolMask(pnt15,msk15)["in"];
pln16 = Plane.ByOriginNormal(pnt16,Vector.ZAxis());
rec16 = Rectangle.ByWidthLength(pln16,s1,s1);
srf16 = (rec16.Patch()).Intersect(bdr.Patch());
bdr16 = srf16.PerimeterCurves();
srf17 = GeometryColor.ByGeometryColor(srf16,Color.ByARGB(255,255,228,181));

//Small Squares
pnt21 = Point.ByCoordinates((0..#n1*2..s1),(0..n1*2-1));
pnt22 = pnt21.Translate(s2/2,s2/2,0);
pnt23 = pnt22<1>.Translate(0..(-s2*n2),0..(s1-s2)*n2..s1,0);
pnt24 = pnt22<1>.Translate(s2..(s2*n2),-s1..(s1-s2)*-n2..-s1,0);
pnt25 = List.Flatten([pnt23,pnt24],-1);
msk25 = bdr.ContainmentTest(pnt25);
pnt26 = List.FilterByBoolMask(pnt25,msk25)["in"];
pln26 = Plane.ByOriginNormal(pnt26,Vector.ZAxis());
rec26 = Rectangle.ByWidthLength(pln26,s2,s2);
srf26 = (rec26.Patch()).Intersect(bdr.Patch());
bdr26 = srf26.PerimeterCurves();
srf27 = GeometryColor.ByGeometryColor(srf26,Color.ByARGB(255,0,0,255));

srfs = [srf17,srf27];
bdrs = [bdr16,bdr26];
[srfs, bdrs];
```


# Triangle subdivision

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-0DNpHg0JVwj5DS2H%2F-Lg-0RcVBp-GP-mWcUxF%2FsubTriangles.gif?alt=media\&token=a5873b2b-b753-41a8-a72f-e879bfc4f1ba)

{% file src="/files/-Lg-0V1fdCe8tEn6nZqo" %}

```d
c0 = t.Explode();
c1 = c0[0];
c2 = c1.StartPoint.DoesIntersect(c0[1])?c0[2]:c0[1];
c3 = c1.StartPoint.DoesIntersect(c0[1])?c0[1]:c0[2];
d1 = Vector.ByTwoPoints(c1.EndPoint,c2.Intersect(c3));
p1 = c1.PointAtParameter(0..1..#n+1);
d2 = List.TakeItems(0..#n+1..(c2.Length/n),1..n+1);
p3 = List.Flatten(p1<1>.Translate(d1,d2<1><2>)<1>,-1);
//Triangle Vertex Groups
p11 = List.DropItems(p3,-1);
p12 = List.DropItems(List.Sublists(List.RestOfItems(p3)<1>,0..1,1)<1>,-1);
p13 = List.Flatten(List.Transpose(List.Transpose([p11,p12])<1>)<1><2>,-1);
p14 = List.DropItems(List.DropItems(List.DropItems(p3,2)<1>,-1)<1>,1);
p15 = List.DropItems(List.Sublists(List.DropItems(p11,1)<1>,0..1,1)<1>,-1);
p16 = List.Flatten(List.Transpose(List.Transpose([p14,p15])<1>)<1><2>,-1);
p17 = List.Clean(List.Flatten(List.Transpose([p13,p16]),2),false);
```


# Vector Field

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzqYLclussRYOek-lJ%2F-LfzqdT9jvwO-8b5wOtk%2FvectorField.png?alt=media\&token=aa4068c6-b1ee-42bf-b24a-4f5d948a25f7)

{% file src="/files/-LfzrOJlOEUTU975FaKP" %}

```d
v = Vector.ByCoordinates
(0.2*p.Y,1);

l = Math.RemapRange(v.Length,3,5);
f = List.Clean(
Line.ByStartPointDirectionLength
(p,v,l),false);
```

```d
v = Vector.ByCoordinates
(-p.Y,-p.X);

l = Math.RemapRange(v.Length,3,5);
f = List.Clean(
Line.ByStartPointDirectionLength
(p,v,l),false);
```

```d
v = Vector.ByCoordinates
(-p.Y,p.X);

l = Math.RemapRange(v.Length,3,5);
f = List.Clean
(Line.ByStartPointDirectionLength
(p,v,l),false);
```

```d
v = Vector.ByCoordinates
(p.X,p.Y);

l = Math.RemapRange(v.Length,3,5);
f = List.Clean
(Line.ByStartPointDirectionLength
(p,v,l),false);
```


# Voronoi

Density dependent on image brightness

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M5AUAU6H9qFQZ-p77ui%2F-M5AUgtuLqIocw0Q_XB0%2FimgVor_2020-04-04_10-08-14.png?alt=media\&token=48d8e152-e329-438e-bcd4-11d2f30902f2)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M5AUAU6H9qFQZ-p77ui%2F-M5AUmsjsK3jHa5vP6BW%2Fgradient.jpg?alt=media\&token=2e30967c-cd4b-4f45-bba5-f96ff70fab9e)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M5AUAU6H9qFQZ-p77ui%2F-M5AUrht9JJDHYjRCwp5%2FimgVor_2020-04-04_10-08-34.png?alt=media\&token=1beaee7c-0c21-4738-9c3e-5e79889c77d6)

{% file src="/files/-M5AUvum7VHKWArPBi-T" %}
ver 2.7
{% endfile %}


# Waves

#### Imperative

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-BiQlSQhSKUYshELs%2F-Lg-BoHQN_YANZpk1Sl3%2Fwaves1.gif?alt=media\&token=501826dc-e25d-4a5c-b99c-744f403dce1a)

```d
def abc(a,b)
{
	ab = [Imperative]
	{
		y = [][];
		c = 0;
		d = 0;
		e = List.OfRepeatedItem(0,b);
		while (c<a)
		{
			f = Math.RandomList(b);
			while (d<b)
			{
				y[c][d] = f[d]+e[d];
				e[d] = y[c][d];
				d = d + 1;
			}
			c = c + 1;
			d = 0;
		}
		return = y;
	}
	e = Point.ByCoordinates((0..5..#a),ab<1>);
	f = NurbsCurve.ByControlPoints(e,3);
	return f;
};
```

#### Associative

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-BiQlSQhSKUYshELs%2F-Lg-Bsrpk4oGFvHuL2j7%2Fwaves2.gif?alt=media\&token=e96b7a74-e06a-4378-9302-5143b0ccbd44)

```d
rndLst1 = Math.RandomList(xCount*yCount);
rndLst2 = List.Chop(rndLst1,yCount);
rndLst3 = List.TakeItems(rndLst2<1>,1..yCount);
rndLst4 = Math.Sum(rndLst3);
nrbCrv1 = NurbsCurve.ByControlPoints(List.Transpose
(Point.ByCoordinates((0..5..#xCount),rndLst4)),3);
```


# Weave

Image based weave pattern

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M55Ju2J1xeTDEnDfAHo%2F-M55MlvlOyoYeEj3MdXu%2Fweave1_2020-04-17_09-51-34.png?alt=media\&token=c6405f60-1dde-4c8e-9630-92fce21002af)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M55Ju2J1xeTDEnDfAHo%2F-M55MHhfsnFsaStxRpkw%2Fweave1_2020-04-17_09-48-29.png?alt=media\&token=9c1aa88a-9357-49fc-87cf-1231b9f43b03)

{% file src="/files/-M55Kukz\_wHwsxr3\_WyS" %}
ver 2.7
{% endfile %}

```d

//Sample Surface
sr = Surface.ByLoft([NurbsCurve.ByPoints(Point.ByCoordinates
(-50,[0,12,1,3],[0,25,50,75])),NurbsCurve.ByPoints
(Point.ByCoordinates(50,[0,-8,1,4],[0,30,62,75]))]);

//Image repetition
n = 7;

//Replicating brightness data
b1 = Math.Floor(Color.Brightness(Image.Pixels(img,8,8)));
b2 = List.Flatten(List.OfRepeatedItem(List.Flatten
(List.OfRepeatedItem(b1<1>,n)<1>,-1),n),1);

// Parameters on surface
c = 0..1..# (8*n);

//Shifting points by brightness normal to surface
p1 = Surface.PointAtParameter(sr,c<1>,c<2>);
v1 = Surface.NormalAtPoint(sr,p1);
v2 = v1.Scale(b2==0?-1:b2);
v3 = List.Transpose(v1).Scale(b2==0?1:-1);
p2 = p1.Add(v2);
p3 = List.Transpose(p1).Add(v3);

//Loft based on curve connecting points
n1 = List.Flatten(NurbsCurve.ByPoints([p2,p3]),-1);
n2 = Circle.ByPlaneRadius(n1<1>.PlaneAtParameter(0..1..#60)<2>,0.25);
n3 = Solid.ByLoft(n2,n1);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M588kPknHCmShr2XK53%2F-M588x0HU1JGKXsQl-KA%2Fweave2_2020-04-17_10-38-01.png?alt=media\&token=25d52933-ab21-4ed6-8e7a-6d9a11002535)

{% file src="/files/-M589I5oVQTHX6KtjOQ5" %}
ver 2.7
{% endfile %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M55Ju2J1xeTDEnDfAHo%2F-M55KJFcim5AN1DWszqy%2Fweave_2020-04-17_05-51-17.png?alt=media\&token=371cf541-0e32-4379-b0b2-6b920f69bcf6)

{% file src="/files/-M55L144wx8TrUUUOTUR" %}
ver 2.7
{% endfile %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-M55Ju2J1xeTDEnDfAHo%2F-M55KWbE--HQtXYnkDqI%2Fweave.jpeg?alt=media\&token=d7b297c6-97f7-467e-8555-cbaa76743a30)


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


# Bridging parallel curves

Orthogonal Spacing of beams along Parallel two Curves

#### Spacing based on maximum distance between consecutive beams

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzlQ93mag3CLk0wMil%2F-LfzmvWajWVwJqKsLdM9%2FPath-20190217.png?alt=media\&token=f84beefd-8b67-48ca-a546-440ac169c8c6)

{% file src="/files/-LfznrNOarVM69CRhYEw" %}

```d
//Two Parallel Curves

a1 = Arc.ByCenterPointStartPointSweepAngle
(Point.ByCoordinates(0,10000),Point.Origin(),
90,Vector.ZAxis());
l1 = Line.ByStartPointDirectionLength
(a1.EndPoint,Vector.YAxis(),20000);
a2 = Arc.ByCenterPointStartPointSweepAngle
(Point.ByCoordinates(20000,30000),
l1.EndPoint,-90,Vector.ZAxis());
a3 = a1.Offset(5000);
l2 = l1.Offset(-5000);
a4 = a2.Offset(-5000);
p1 = PolyCurve.ByJoinedCurves([a1,l1,a2]);
p2 = PolyCurve.ByJoinedCurves([a3,l2,a4]);
n1 = NurbsCurve.ByPoints(p1.PointAtParameter(0..1..#100));
n2 = NurbsCurve.ByPoints(p2.PointAtParameter(0..1..#100));
```

```d
//Orthogonal Beams

max = 1000;
pt1 = br2(cr1,cr2,max);
pt2 = cr2.ClosestPointTo(pt1);
ln1 = Line.ByStartPointEndPoint(pt1,pt2);
[cr1,cr2,ln1];

//Points Spacing - Curve 1
d11 = List.DropItems(List.Sublists(pt1,0..1,1),-1);
d12 = Math.Round(List.FirstItem(d11<1>).DistanceTo(List.LastItem(d11<1>)));


//Points Spacing - Curve 2
d11 = List.DropItems(List.Sublists(pt2,0..1,1),-1);
d12 = Math.Round(List.FirstItem(d11<1>).DistanceTo(List.LastItem(d11<1>)));
```

```d
def br1(c1,c2,p1,s1)
{
	r1 = c1.ParameterAtPoint(p1);
	p2 = c2.ClosestPointTo(p1);
	r2 = c2.ParameterAtPoint(p2);
	p3 = c2.PointAtChordLength(s1,r2,true);
	p4 = c1.ClosestPointTo(p3);
	d1 = p1.DistanceTo(p4);
	p5 = d1<=s1?p4:c1.PointAtChordLength(s1,r1,true);
	pr = d1<=s1?c2.ParameterAtPoint(p5):c1.ParameterAtPoint(p5);
	return = [p5,pr];
};

def br2(c1,c2,s1)
{
	return = [Imperative]
	{
		n = 0;
		ct = 0;
		q = Math.Ceiling(c1.Length/s1);
		p1 = c1.StartPoint;
		p3 = [];
		while (ct < 1)
		{
			p3[n] = List.FirstItem(br1(c1,c2,p1,s1));
			ct = List.LastItem(br1(c1,c2,p1,s1));
			p1 = p3[n];
			n = n + 1;
		}
		return = p3;
	}
};
```

#### Spacing based on maximum area between consecutive beams

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzlQ93mag3CLk0wMil%2F-LfznDiQ6XynMmQf1GXz%2FPath-Area.png?alt=media\&token=18c8f9cd-d68d-4060-8782-b8aa4cd5d696)

{% file src="/files/-LfznoGxKvwkWwJwBW-u" %}

```d
// Orthogonal Beams

//Max are in sqm
max = 10;
//Reduce beam spacing increment (mm) for greater accuracy
spc = 100;

pt1 = br2(cr1,cr2,spc);
pt2 = cr2.ClosestPointTo(pt1);
ln1 = Line.ByStartPointEndPoint(pt1,pt2);
ln2 = List.DropItems(List.Sublists(ln1,0..1,1),-1);
ar1 = Surface.ByLoft(ln2).Area/1000000;
ar2 = Math.Sum(List.TakeItems(ar1,1..List.Count(ar1)));
ln3 = List.GroupByKey(List.RestOfItems(ln1),Math.Ceiling(ar2/max))["groups"];

// Beams spaced with desired area between them
ln4 = List.AddItemToFront(List.FirstItem(ln1),List.LastItem(ln3<1>));
[cr1,cr2,ln4];

//Area between two beams
ar3 = Math.Round(Surface.ByLoft(List.DropItems(List.Sublists(ln4,0..1,1),-1)).Area/1000000);
```

```d
def br1(c1,c2,p1,s1)
{
	r1 = c1.ParameterAtPoint(p1);
	p2 = c2.ClosestPointTo(p1);
	r2 = c2.ParameterAtPoint(p2);
	p3 = c2.PointAtChordLength(s1,r2,true);
	p4 = c1.ClosestPointTo(p3);
	d1 = p1.DistanceTo(p4);
	p5 = d1<=s1?p4:c1.PointAtChordLength(s1,r1,true);
	pr = d1<=s1?c2.ParameterAtPoint(p5):c1.ParameterAtPoint(p5);
	return = [p5,pr];
};

def br2(c1,c2,s1)
{
	return = [Imperative]
	{
		n = 0;
		ct = 0;
		q = Math.Ceiling(c1.Length/s1);
		p1 = c1.StartPoint;
		p3 = [];
		while (ct < 1)
		{
			p3[n] = List.FirstItem(br1(c1,c2,p1,s1));
			ct = List.LastItem(br1(c1,c2,p1,s1));
			p1 = p3[n];
			n = n + 1;
		}
		return = List.Flatten([c1.StartPoint,p3],-1);
	}
};
```


# British Museum Great Court

Roof Surface Geometry

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MG_7ZEltTOuMbmy2qun%2F-MG_8-30jpEEl1R-Wqkp%2FBritishMuseumGreatCourtRoof-1_2020-09-07_01-37-17.png?alt=media\&token=696af8c9-8247-4399-82c0-c14bdfc2e57a)

{% file src="/files/-MG\_8gIHxmrBBBwFe32N" %}
THE ANALYTIC AND NUMERICAL DEFINITION OF THE GEOMETRY OF THE BRITISH MUSEUM GREAT COURT ROOF
{% endfile %}

{% file src="/files/-MG\_86c\_vnD2ZvvKUMKD" %}
Dynamo 2.9
{% endfile %}

```d
def z (x:var[]..[], y:var[]..[])
{
a = 22.245;
b = 36.625;
c = 46.025;
d = 51.125;

//λ
lm = 0.5;

//μ
mu = 14.0;

hcen = 20.955;
hedg = 19.71;
r = Math.Sqrt(Math.Pow(x,2)+Math.Pow(y,2));

//θ
the = Math.Asin(y/r);

//η
eta = (1-(x/b)) * (1+(x/b)) * (1-(y/c)) * (1+(y/d))/
(1-((a*x)/(r*b))) * (1+((a*x)/(r*b))) * (1-((a*y)/(r*c))) * (1+((a*y)/(r*d)));

//Ψ
psi = (1-(x/b)) * (1+(x/b)) * (1-(y/c)) * (1+(y/d));

//α
alp = ((r/a)-1) * psi;

//β
bet = (1-(a/r))/
(((Math.Sqrt(Math.Pow(b-x,2) + Math.Pow(c-y,2))) / ((b-x)*(c-y))) +
((Math.Sqrt(Math.Pow(b-x,2) + Math.Pow(d+y,2))) / ((b-x) * (d+y))) +
((Math.Sqrt(Math.Pow(b+x,2) + Math.Pow(c-y,2))) / ((b+x) * (c-y))) +
((Math.Sqrt(Math.Pow(b+x,2) + Math.Pow(d+y,2))) / ((b+x)*(d+y))));

z1 = ((hcen - hedg)*eta) + hedg;
z2 = alp * (((1-lm)*(((35.0+(10.0*psi))*0.5*(1+Math.Cos(2*the)))+(12.0*(0.5*(1-Math.Cos(2*the))+Math.Sin(the)))+((7.5+(12.0*psi))*(0.5*(1-Math.Cos(2*the))-Math.Sin(the)))-1.6))
- ((5.0*(1+Math.Cos(2*the)))+(10.0*(Math.Pow((0.5*(0.5*(1-Math.Cos(2*the))+Math.Sin(the))),2))*(1.0-(3.0*alp))))
+ (2.5*(Math.Pow((0.5*(0.5*(1-Math.Cos(2*the)-Math.Sin(the)))),2))*(Math.Pow(((r/a)-1),2))));
z3 = bet * ((lm*((1.75*(1+Math.Cos(2*the)))+(1.5*(1-Math.Cos(2*the)))+(0.3*Math.Sin(the))))
+ (1.05*(Math.Pow(Math.E,-mu*(1-(x/b)))+Math.Pow(Math.E,-mu*(1+(x/b))))*(Math.Pow(Math.E,-mu*(1-(y/c)))+Math.Pow(Math.E,-mu*(1+(y/d))))));
return = z1 + z2 +z3;
};

x =-36.6..36.6..#30;
y = -51.125..46.025..#30;
p = NurbsSurface.ByPoints(Point.ByCoordinates(x<1>,y<2>).Translate(Vector.ByCoordinates(0,0,z(x<1>,y<2>)))).Trim(Plane.ByOriginNormal(Point.ByCoordinates(0,0,19.71),Vector.ZAxis()),Point.Origin());
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MG_7ZEltTOuMbmy2qun%2F-MG_8O5VnGCcMfNT3fHZ%2FBritishMuseumGreatCourtRoof-2_2020-09-07_01-37-57.png?alt=media\&token=a13e1897-4eff-44ab-a41d-7fa31345aedc)

{% file src="/files/-MG\_8TEDFd4raCIv0s0V" %}
Dynamo 2.7
{% endfile %}

```d
cen1 = Circle.ByCenterPointRadius(Point.Origin(),15);
edg1 = Rectangle.ByWidthLength(73,97).Translate(Vector.YAxis(),3);
pnt1 = (edg1.Explode())<1>.PointAtParameter((0..1..#10)<2>);
pnt2 = cen1.ClosestPointTo(pnt1);
pnt3 = Line.ByStartPointEndPoint(pnt1,pnt2).PointAtParameter(0.5).Translate(Vector.ZAxis(),6);
pnt4 = List.Transpose(Arc.ByThreePoints(pnt1,pnt3,pnt2))<1>.PointAtParameter((0..1..#10)<2>);
pnt5 = Point.PruneDuplicates(List.Flatten(pnt4<1>,-1),0.001);
srf1 = Surface.ByLoft(List.AddItemToFront(edg1,List.RestOfItems(NurbsCurve.ByControlPoints(pnt5,3,true))));
```


# Catenary

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfPifkM9p0Dd5VyY16Y%2F-LfPjhWx9nJXVq2icbsQ%2Fcatenary-20180119.png?alt=media\&token=e538334b-a804-4453-8c64-75ebbde6f7cb)

```d
p1 = Point.ByCoordinates(7,8,25).Translate(Vector.YAxis(),0..50..10);
p2 = Point.ByCoordinates(50,-5,20).Translate(Vector.YAxis(),0..50..10);
a = 10..50..#6;
l=Line.ByStartPointEndPoint(p1,p2);
x=(-l.Length/2)..(l.Length/2)..0.1;
z=a*Math.Cosh(x/a);
p3=Point.ByCoordinates(x,0,z);
p4=p3.Translate(Vector.ZAxis(),-List.FirstItem(p3<1>).Z);

or=l.PointAtParameter(0.5);
vx=Vector.ByTwoPoints(or,l.PointAtParameter(1));
vy=Vector.ByTwoPoints(or,or.Translate(Vector.YAxis(),1));
cs=CoordinateSystem.ByOriginVectors(or,vx,vy);
p5=p4.Transform(cs);
ct=NurbsCurve.ByPoints(p5);
[p1,p2,ct];
```


# Delete Adjacent

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLvzj3k7_xVuyOpELJ%2F-LhLw9kKzqkA7KtRjS_n%2FdeleteAdjacent.png?alt=media\&token=cc2f67e0-4855-4e6e-93fa-f36d01c19108)

{% file src="/files/-LhLwnMKNacBG6nopKXL" %}

```d
t13 = 4497;
t14 = 5;
t15 = 150;
Building_area_width = t15;
unit_width = t14;
unit_count_x_direction_floating = (Building_area_width / unit_width) - 0.49;
unit_count_x_direction_integer = Math.Round(unit_count_x_direction_floating);
t16 = t14 * unit_count_x_direction_integer;
t17 = t16 / 2;
t18 = t14 / 2;
t19 = t17 - t18;
t20 = t19 * -1;
t21 = (t20..#unit_count_x_direction_integer..t14);
t22 = 10;
t23 = 200;
Building_area_length = t23;
unit_length = t22;
unit_count_y_direction_floating = (Building_area_length / unit_length) - 0.49;
unit_count_y_direction_integer = Math.Round(unit_count_y_direction_floating);
t24 = t22 * unit_count_y_direction_integer;
t25 = t24 / 2;
t26 = t22 / 2;
t27 = t25 - t26;
t28 = t27 * -1;
t29 = (t28..#unit_count_y_direction_integer..t22);
t30 = 4;
t31 = t30 / 2;
t32 = 6;
t33 = (t31..#t32..t30);
point2 = Point.ByCoordinates(t21<1>, t29<2>, t33<3>);
cuboid1 = Cuboid.ByLengths(point2, t14, t22, t30);
t34 = 0;
t35 = 0;
Building_area_origin_X = t34;
Building_area_origin_Y = t35;
point1 = Point.ByCoordinates(Building_area_origin_X, Building_area_origin_Y, 0);
vector1 = Vector.ZAxis();
t36 = 0;
geometry1 = Geometry.Rotate(cuboid1, point1, vector1, t36);
t37 = t15 * 2;
t38 = t23 * 2;
t39 = t30 * t32;
cuboid2 = Cuboid.ByLengths(point1, t37, t38, t39);
vector2 = Vector.ZAxis();
t40 = t39 / 2;
geometry2 = Geometry.Translate(cuboid2, vector2, t40);
t41 = 0;
geometry3 = Geometry.Rotate(geometry2, point1, vector2, t41);
cuboid3 = Cuboid.ByLengths(point1, t15, t23, t39);
vector3 = Vector.ZAxis();
geometry4 = Geometry.Translate(cuboid3, vector3, t40);
geometry5 = Geometry.Rotate(geometry4, point1, vector3, t41);
solid1 = Solid.Difference(geometry3, geometry5);
t42 = Geometry.DoesIntersect(geometry1, solid1);
t43 = List.FilterByBoolMask(geometry1, t42);
t44 = Dictionary.ValueAtKey(t43, "in");
t45 = Dictionary.ValueAtKey(t43, "out");
t46 = List.Flatten(t45, -1);
t47 = 0;
t48 = 0;
t49 = 0;
point3 = Point.ByCoordinates(t47, t48, t49);
t50 = 80;
t51 = 50;
t52 = 50;
cuboid4 = Cuboid.ByLengths(point3, t50, t51, t52);
vector4 = Vector.ZAxis();
t53 = t52 / 2;
geometry6 = Geometry.Translate(cuboid4, vector4, t53);
vector5 = Vector.ZAxis();
t54 = 0;
geometry7 = Geometry.Rotate(geometry6, point3, vector5, t54);
t55 = Geometry.DoesIntersect(t46, geometry7);
t56 = List.FilterByBoolMask(t46, t55);
t57 = Dictionary.ValueAtKey(t56, "in");
t58 = Dictionary.ValueAtKey(t56, "out");
t59 = List.Flatten(t58, -1);
solid2 = Solid.ByUnion(t59);
solid3 = Solid.Difference(solid2, t59);
face1 = Topology.Faces(solid3);
t60 = List.Count(face1<1L>);
face2 = Topology.Faces(solid2);
t61 = List.Count(face2);
t62 = t60 - t61;
t63 = 6;
t64 = t62 < t63;
t65 = List.FilterByBoolMask(t59, t64);
t66 = Dictionary.ValueAtKey(t65, "in");
t67 = Dictionary.ValueAtKey(t65, "out");
t68 = DSCore.Object.Identity(t66);
t69 = DSCore.Object.Identity(t67);
t70 = 12000;
t71 = t14 * t22;
t72 = t70 / t71;
t73 = Math.Round(t72);
cuboid5 = Cuboid.ByLengths(point1, t15, t23, 1);
vector6 = Vector.ZAxis();
t74 = -0.5;
geometry8 = Geometry.Translate(cuboid5, vector6, t74);
vector7 = Vector.ZAxis();
geometry9 = Geometry.Rotate(geometry8, point1, vector7, t41);
```


# Geodesic Sphere

Geodesic Sphere based on an Icosahedron

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MkjjMLkeyHZRws05Hae%2F-MkjjY_QaE5DkesxLPLQ%2FgeodesicSphere_20210929_2021-09-29_08-29-35.png?alt=media\&token=075f686f-8156-44a1-894f-1d8bc9c347d8)

```d
// Radius
rad = 12;

// Division Depth
d = 9;

// Icosahedron
p = (1+Math.Sqrt(5))/2;
a = Point.ByCoordinates([0,0,0,0,p,-p,-p,p,1,-1,-1,1],[1,-1,-1,1,0,0,0,0,p,p,-p,-p],[p,p,-p,-p,1,1,-1,-1,0,0,0,0]);
b = [[a[0],a[8],a[9]],[a[0],a[9],a[5]],[a[0],a[5],a[1]],[a[0],a[1],a[4]],[a[0],a[4],a[8]],
[a[1],a[5],a[10]],[a[1],a[10],a[11]],[a[1],a[11],a[4]],[a[2],a[3],a[7]],[a[2],a[7],a[11]],
[a[2],a[11],a[10]],[a[2],a[10],a[6]],[a[2],a[6],a[3]],[a[3],a[6],a[9]],[a[3],a[9],a[8]],
[a[3],a[8],a[7]],[a[4],a[11],a[7]],[a[4],a[7],a[8]],[a[5],a[9],a[6]],[a[5],a[6],a[10]]];
tri = Surface.ByPerimeterPoints(b);

// Sub dividing equilateral faces
// Edges of equilateral surface
crv1 = tri.PerimeterCurves();
len1 = List.GetItemAtIndex(crv1<1>,0).Length;
n = d<1?1:d;
len2 = len1/n;

// Vertices of equilateral surface
pnt1 = List.GetItemAtIndex(crv1<1>,0).StartPoint;
pnt2 = List.GetItemAtIndex(crv1<1>,1).StartPoint;
pnt3 = List.GetItemAtIndex(crv1<1>,2).StartPoint;

dir1 = Vector.ByTwoPoints(pnt1,pnt2);
dir2 = Vector.ByTwoPoints(pnt1,pnt3);
dir3 = Vector.ByTwoPoints(pnt2,pnt3);

// Sub triangle 1
pnt4 = pnt1.Translate(dir1,len2);
pnt5 = pnt1.Translate(dir2,len2);
sub1 = Polygon.ByPoints(Transpose([pnt1,pnt4,pnt5]));

// Repeating sub triangle
n2 = (0..(n-1))*len2<1>;
sub2 = sub1.Translate(dir1,n2);
n3 = List.TakeItems(n2<1>,1..n);
sub3 = sub2.Translate(dir3,n3);

// Sub triangle 2
pnt6 = n<2?pnt1:pnt4.Translate(dir2,len2);
sub4 = Polygon.ByPoints(Transpose([pnt4,pnt5,pnt6]));
n4 = (0..(n-2))*len2<1>;
sub5 = sub4.Translate(dir1,n4);
n5 = List.TakeItems(n4<1>,1..n);
sub6 = sub5.Translate(dir3,n5);

sub21 = List.Flatten(List.TakeItems([sub3,sub6],n),-1);

plPnt1 = List.Flatten(sub21).Points;
plDir1 = Vector.ByTwoPoints(Point.Origin(),plPnt1);

sph = Sphere.ByCenterPointRadius(Point.Origin(),rad);
plPnt21 = List.Flatten(sph.ProjectInputOnto(plPnt1,plDir1)<1>,-1);
pl1 = Polygon.ByPoints(plPnt21);
sr1 = pl1.Patch();

sr2 = GeometryColor.ByGeometryColor(List.Transpose(List.Chop(sr1,4)),
Color.ByARGB(255,[115,105,25,200],[200,100,56,169],26));
```


# Group Branching Curves

Triangular loops from branching curves

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh99t19D8bhkPhs2Q1X%2F-Lh9AaisLJyF-ikUfMR0%2FtriSrf1.png?alt=media\&token=1312a3c1-6621-47bc-9721-432fbca00c66)

```d
//All Vertices (Start and End Points of Lines)
a = Point.PruneDuplicates(List.Flatten([lns.StartPoint,lns.EndPoint],-1));

//Index of Start and End Points in list of Vertices
b = List.Transpose([List.IndexOf(a,lns.StartPoint),List.IndexOf(a,lns.EndPoint)]);
c = List.Flatten(List.Permutations(b,3)<1>,-1);

//Obtain indices of connected vertices
d = List.GetItemAtIndex(c<2>,(0..5)<1>);
e1 = d[0]==d[5] && d[1]==d[2] && d[3]==d[4];
e2 = d[1]==d[5] && d[0]==d[2] && d[3]==d[4];
f = List.UniqueItems(List.FilterByBoolMask(c,e1 || e2)["in"]<1>);
g = List.UniqueItems(List.Sort(f));
h = List.GetItemAtIndex(a,g);

//Surfaces
srf = Surface.ByPerimeterPoints(h);
```

```d
//Sample Lines
Line.ByStartPointEndPoint(Point.ByCoordinates([0,0,1,1,12,7,15,12],
[0,0,9,9,10,5,6,1]),Point.ByCoordinates([7,1,7,12,7,15,12,7],[5,9,5,10,5,6,1,5]));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh99t19D8bhkPhs2Q1X%2F-Lh9AX_94K70Mi8RWbBT%2FtriSrf2.png?alt=media\&token=c650ea44-282d-4925-8fdc-b36d2dcebc7f)


# Group Circles

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh9LU6PlaTzhtdSChvF%2F-Lh9LegEnMZIYBxlLLKe%2FgroupCircles.png?alt=media\&token=f75c1fa1-433b-4d7c-bdc0-abecd9761ce2)

{% file src="/files/-Lh9LiXCCZj3e00YiIZB" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh9LU6PlaTzhtdSChvF%2F-Lh9M9BNFMvZM3i2Ek6l%2FgroupCircles_2019-06-12_11-54-43.png?alt=media\&token=ea874794-729a-4ad1-b0c0-f3b37b91bcf0)

```d
circle1 = Circle.ByCenterPointRadius(Point.ByCoordinates([2, 12, 6, 9, 3, 6], [1, 4, 8, 7, 8, 2]), [1, 2, 1, 2, 2, 2]);
t2 = Geometry.DistanceTo(circle1<1>, circle1<2>);
t3 = List.SortByKey(circle1, t2@L2<1>);
t4 = Dictionary.ValueAtKey(t3, "sorted list");
t5 = Dictionary.ValueAtKey(t3, "sorted keys");
t6 = 2;
t7 = List.TakeItems(t4<1L>, t6<1L>);
t8 = 1;
t9 = List.GetItemAtIndex(t5<1L>, t8<1L>);
t10 = 0.5;
t11 = t9 <= t10;
t12 = List.FilterByBoolMask(t7, t11);
t13 = Dictionary.ValueAtKey(t12, "in");
t14 = Dictionary.ValueAtKey(t12, "out");
t15 = List.Sort(t13<1L>);
t16 = List.UniqueItems(t15);
point1 = Circle.CenterPoint(t16);
line1 = Line.ByBestFitThroughPoints(point1);
t17 = Circle.Radius(t16);
t18 = List.FirstItem(t17<1L>);
curve1 = Curve.ExtendStart(line1, t18);
t19 = List.LastItem(t17<1L>);
curve2 = Curve.ExtendEnd(curve1, t19);
t20 = List.MaximumItem(t17);
t21 = 2;
t22 = t20 * t21;
vector1 = Vector.ZAxis();
polyCurve1 = PolyCurve.ByThickeningCurve(curve2, t22, vector1);
a = circle1;
b = polyCurve1;
t1 = [a, b];
```


# Group curves

Design script definition that groups a list of shuffled curves into loops…

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfOM0xCZDUh0S5wlS43%2F-LfOa89FIT_LUAEArzpW%2FgroupCurves-1.gif?alt=media\&token=078663a7-a606-43aa-9150-dcd877f3e949)

```d
def grpCrvs(crv:var[]..[])
    {
    	dis1 = (crv.StartPoint)<1>.DistanceTo(crv<2>)==0
        ||(crv.EndPoint)<1>.DistanceTo(crv<2>)==0;
    	ind1 = List.AllIndicesOf(dis1<1>,true);
    	bln1 = true;
    	ind2 = [Imperative]
    	{
    		while (bln1)
    		{
    			cnt1 = List.Count(ind1);
    			ind1 = grpIndx(ind1);
    			cnt2 = List.Count(ind1);
    			bln1 = cnt2!=cnt1;
    		}
    		return = ind1;
    	}
    	crv1 = List.GetItemAtIndex(crv,ind2);
    	return = crv1;
    };

    def grpIndx(ind:var[]..[])
    {
    	ind1 = List.SetIntersection(ind<1>,ind<2>);
    	cnt1 = List.Count(ind1<1><2>)>0;
    	ind2 = List.FilterByBoolMask(ind,cnt1<1>)["in"];
    	ind3 = List.UniqueItems(List.Flatten(ind2<1>,-1)<1>);
    	ind4 = List.UniqueItems(List.Sort(ind3<1>));
    	return = ind4;
    };
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfOM0xCZDUh0S5wlS43%2F-LfOahDqLWKFrh_ba0qJ%2FgroupCurves-2.png?alt=media\&token=001823a8-f3ed-43e5-afad-e0559cf7cc18)


# K Mean

K-Means is one of the most popular "clustering" algorithms

K-means stores **k** centroids that it uses to define clusters. A point is considered to be in a particular cluster if it is closer to that cluster's centroid than any other centroid.

![Grouping points into k (no.s) clusters](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MjDvmtTH-1l6R84mCcw%2F-MjDw6lFpiVErPvKSEF4%2FKmeans-20210910-1_2021-09-10_02-25-22.png?alt=media\&token=6cc475fa-ac14-4500-8e9c-ed1b91e56d6e)

<https://stanford.edu/~cpiech/cs221/handouts/kmeans.html>

```d
// Group by Centroid
def k1(pnts:var[]..[],cnts:var[]..[])
{
	//Labels
	lbl1 = "A"..#(List.Count(cnts))..1;

	//Distance to Centroids
	dst1 = pnts<1>.DistanceTo(cnts<2>);
	dst2 = List.SortByKey(lbl1,dst1<1>);
	dst3 = List.FirstItem(dst2["sortedList"]<1>);

	//Group by Closest to Centroid
	pnt1 = List.GroupByKey(pnts,dst3)["groups"];
	return pnt1;
};

// Centroid
def ctr (pnts:var[]..[])
{
	return Point.ByCoordinates(Math.Average(pnts.X),
	Math.Average(pnts.Y),Math.Average(pnts.Z));
};

// K Mean
def kMean (pnts:var[]..[],k:int)
{
	pnt1 = k1(pnts,pnts[1..k]);
	cnt1 = 1;
	pnt2 = [];
	pts1 = [Imperative]
	{
		while (cnt1 <= k)
		{
			ctr1 = ctr(pnt1);
			pnt2 = k1(List.Flatten(pnt1,-1),ctr1);
			cnt1 = cnt1 + 1;
			pnt1 = pnt2;
		}
		return pnt2;
	}
	return pts1;
};
```


# Nurbs Surface Irregular

Non Rectangular footprint

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MZM8R8k7BHsbUjSRUvk%2F-MZM93KfDr856OmmlZ46%2FnurbsSurfaceIrregular1.png?alt=media\&token=478b43b7-bcc6-4e93-92c6-0884f765e634)

```d
//Base Profile
ln1 = Line.ByStartPointEndPoint(Point.ByCoordinates(-50,0),Point.ByCoordinates(0,-50));
pt1 = ln1.PointAtParameter(0..1..#9).Translate(Vector.ByCoordinates(-1,-1,0),[0,5,0,0,5,0,0,5,0]);
pg1 = Polygon.ByPoints(List.Flatten(List.RestOfItems(pt1).Rotate(Point.Origin(),Vector.ZAxis(),(90..#4..90)<1>),-1));

//Nurbs Surface
pt2 = Point.ByCoordinates((-60..60..15)<1>,(-60..60..15)<2>);
bl1 = pt2.DoesIntersect(pg1.Patch());
ds1 = bl1? pt2.DistanceTo(pg1) : 0;
pt3 = pt2.Translate(Vector.ZAxis(),ds1/2);
ns1 = NurbsSurface.ByPoints(pt3,3,3);

nc2 = PolyCurve.ByJoinedCurves(pg1.PullOntoSurface(ns1));
ns2 = ns1.TrimWithEdgeLoops(nc2);
ns3 = GeometryColor.ByGeometryColor(ns2,Color.ByARGB(250,220,120,20));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MZM8R8k7BHsbUjSRUvk%2F-MZM9A8njyXz_1ZIgkby%2FnurbsSurfaceIrregular2.png?alt=media\&token=a9c22fff-dddc-40e2-9dd0-170b8f48bb51)

```d
//Base Profile
ln1 = Line.ByStartPointEndPoint(Point.ByCoordinates(-50,0),Point.ByCoordinates(0,-50));
pt1 = ln1.PointAtParameter(0..1..#9).Translate(Vector.ByCoordinates(-1,-1,0),[0,5,0,0,5,0,0,5,0]);
pg1 = Polygon.ByPoints(List.Flatten(List.RestOfItems(pt1).Rotate(Point.Origin(),Vector.ZAxis(),(90..#4..90)<1>),-1));

//Nurbs Surface
pt2 = Point.ByCoordinates((-60..60..15)<1>,(-60..60..15)<2>);
bl1 = pt2.DoesIntersect(pg1.Patch());
ds1 = bl1? pt2.DistanceTo(pg1) : 0;
pt3 = pt2.Translate(Vector.ZAxis(),ds1/2);
ns1 = NurbsSurface.ByPoints(pt3,3,3);

nc2 = PolyCurve.ByJoinedCurves(pg1.PullOntoSurface(ns1));
ns2 = ns1.TrimWithEdgeLoops(nc2);
ns3 = GeometryColor.ByGeometryColor(ns2,Color.ByARGB(250,220,120,20));
```


# Overlapping Petals

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MMzHHqeUbiVZmsOQhft%2F-MMzI8J5RqEPA_mTGf8R%2Fpetals.png?alt=media\&token=28af1193-8017-49a5-8d42-5a21ce00e168)

```d
//Number of Divisions
ct = 15;

//Thickness of Shell
th = 0.15;

//Base, Mid and Top Profiles
p1 = Point.ByCoordinates(0,0,[0,10,20]);
c1 = Circle.ByCenterPointRadius(p1,[5,7,2]);

//Split Profile Curves
c2 = c1<1>.SplitByParameter((0..1..#ct));

//Rotate and Extend Curves
a1 = Math.Atan((th*1.5)/(c1.Length/ct));
c3 = c2.Rotate(c2.StartPoint,Vector.ZAxis(),a1);
c4 = List.Transpose(c3.ExtendEnd(th));

//Loft and Solid
c5 = NurbsCurve.ByPoints(c4.StartPoint);
s1 = Surface.ByLoft(c4,c5).Thicken(th);
```

{% file src="/files/-MMzIIJvL3xfXedRayVk" %}
Dynamo 2.9
{% endfile %}


# Pair Nearest

Pair nearest while avoiding reverse pairing (unique pairs)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MCeRzSkwQmSiP7bSxwn%2F-MCeSOWcJS7Z8OJ2ATqF%2FnearestPairs_2020-07-20_09-45-38.png?alt=media\&token=ce6ca721-c231-4444-806f-29e4734f6589)

```d
s = PolyCurve.ByJoinedCurves(List.Shuffle(
(Rectangle.ByWidthLength(10..20..#5,5).Translate
(0..40..#5,0..40..#5,0))).Explode());

def cns(cr:var[]..[], oc:var[]..[])
{
	a = List.SetDifference(List.RestOfItems(cr),oc);
	b = cr[0].DistanceTo(a);
	c = List.SortByKey(a,b)["sorted list"];
	return List.FirstItem(c);
};

s;
nearestPairs = [Imperative]
{
	t = [];
	i = 0;
	while (List.Count(t)<List.Count(s))
	{
		d = cns(List.ShiftIndices(s,-i),t);
		t = List.AddItemToEnd(d,t);
		i = i + 1;
	}
	return List.Transpose([s,t]);
};
```

{% file src="/files/-MCeSZFsTgwtzaFJ4z2a" %}
Dynamo version 2.8
{% endfile %}


# Parametric Shapes

Geometry defined by equations

![Associative and Imperative Shape definition](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSkFAd33zVVaUKcOxlM%2F-MSkFcjuiUtSLRS1PQLY%2Fshape_2021-02-04_12-32-50.png?alt=media\&token=0cea4540-0047-48c8-894a-ee25d573f672)

```d
u = 180/2..3*180/2..2;
v = 0..180*2..2;
x = ((3/2) + Math.Sin(u + (2 * v)<1>)) * (Math.Cos(v) + Math.Cos(2 * v)/10);
y = ((3/2) + Math.Sin(u + (2 * v)<1>)) * (Math.Sin(v) + Math.Sin(2 * v)/10);
z = Math.Sin(Math.RadiansToDegrees(Math.Sin(Math.RadiansToDegrees(Math.Cos(u + (2 * v)<1>)<1> + (Math.Cos(12 * u) / 12)))));
s = GeometryColor.ByGeometryColor(NurbsSurface.ByPoints(Point.ByCoordinates(x,y,z)),Color.ByARGB(150,255,150,100));
```

```d
geometry = [Imperative]
{
	a = 0;
	b = 0;
	arrPoints = [];
	for (v in 0..2*180..2)
	{
		for (u in (180/2)..(3*180/2)..2)
		{
			x = ((3/2) + Math.Sin(u+(2*v))) * (Math.Cos(v)+Math.Cos(2*v)/10);
			y = ((3/2) + Math.Sin(u+(2*v))) * (Math.Sin(v)+Math.Sin(2*v)/10);
			z = (Math.Sin(Math.RadiansToDegrees(Math.RadiansToDegrees(Math.Sin(Math.Cos(u+(2*v))+Math.Cos(12*u)/12)))));
			arrPoints [a][b] = Point.ByCoordinates(x, y, z);
			b = b + 1;
		}
		a = a + 1;
		b = 0;
	}
	return List.Clean(NurbsCurve.ByPoints(arrPoints),false);
```

![https://pixabay.com/images/id-331944/](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvGZfPqeRWo5yqmj9a%2F-MOvHPE7M4jWnm02v8gf%2Fpringles-331944_1280.jpg?alt=media\&token=d3c0d3ab-8ad1-4ac8-a386-002f9ca4fed1)

![Hyperbolic Paraboloid](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvGZfPqeRWo5yqmj9a%2F-MOvHggqPXIrQtpP6ZcK%2FPotatoChip_2020-12-17_05-49-36.png?alt=media\&token=77ba3eac-c8be-440f-829b-265d5720b54f)

```d
//Circular Grid of Points
p1 = Point.ByCoordinates(Math.Cos(0..360),Math.Sin(0..360));
p2 = p1.Translate((p1.AsVector())<1>,(-1..10)<2>);

//Equation
a = 5;
b = 8;
z1 = Math.Pow(p2.X,2)/Math.Pow(a,2)-Math.Pow(p2.Y,2)/Math.Pow(b,2);

//Surface
s1 = NurbsSurface.ByPoints(p2.Translate(Vector.ZAxis(),z1));
GeometryColor.ByGeometryColor(s1,Color.ByARGB(255,252,211,3));
```

![Mobius Strip](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg-6cgTmg9yv-GPo7As%2F-Lg-6qNI9COACocROLub%2FmobiusStrip.png?alt=media\&token=f7a0101c-33e1-443e-867d-29bc67104141)

```d
n = 10;
r = 20;
s = -n..n..#100;
t = 0..360..#100;
x = (r + (s<2> * Math.Cos(t/2)<1>)) * Math.Cos(t);
y = (r + (s<2> * Math.Cos(t/2)<1>)) * Math.Sin(t);
z = s<2> * Math.Sin(t/2)<1>;
points = Autodesk.Point.ByCoordinates(x,y,z);
Mobius = NurbsSurface.ByPoints(points)
```

![Hemisphere](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzxXWdfevMLsNaZW16%2F-LfzxdspVpVucx_EvGZw%2FparametricHemisphere.png?alt=media\&token=4307928d-fef0-43ff-b945-849f48b13180)

```d
//Parametric Hemisphere
r = 10;
b = 30;
c = 20;
u = 0..360..#b;
v = 0..r..#c;
x = Math.Sqrt(Math.Pow(r,2)<1>-Math.Pow(v<2>,2)<2>)*Math.Cos(u)<1>;
y = Math.Sqrt(Math.Pow(r,2)<1>-Math.Pow(v<2>,2)<2>)*Math.Sin(u)<1>;
z = v;
p = List.FirstItem(Autodesk.Point.ByCoordinates(x<1><2>,y<1><2>,z)<1>);

//Cross Bracing
dr = List.DiagonalRight(p,c);
pr = PolyCurve.ByPoints(List.FilterByBoolMask(dr,List.Count(dr<1>)>1)["in"],false);
dl = List.DiagonalLeft(p,c);
pl = PolyCurve.ByPoints(List.FilterByBoolMask(dl,List.Count(dl<1>)>1)["in"],false);
dh = List.UniqueItems(List.Transpose(p)<1>);
ph = PolyCurve.ByPoints(List.FilterByBoolMask(dh,List.Count(dh<1>)>1)["in"],false);
```


# Platonic Solids

Regular Polyhedron

&#x20;**Platonic solid**, any of the five geometric **solids** whose faces are all identical, regular polygons meeting at the same three-dimensional angles. Also known as the five regular polyhedra, they consist of the tetrahedron (or pyramid), hexahedron (or cube), octahedron, dodecahedron, and icosahedron.

![Platonic Solids](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MRiIZj0l1W_vCTTrkg5%2F-MRiIxrXwgp8W2lV6_-m%2Fpolyhedron1.gif?alt=media\&token=93559bc9-1c2c-46d7-a14b-cefa867c58ef)

```d
h = (1+Math.Sqrt(5))/2-1;
phd01 = Dictionary.ByKeysValues(["Tetrahedron","Hexahedron","Octahedron","Dodecahedron","Icosahedron"],
[[1,1,1,1,-1,-1,-1,1,-1,-1,-1,1],[1,1,1,1,1,-1,1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,-1],
[0,0,1,0,0,-1,0,1,0,0,-1,0,1,0,0,-1,0,0],[0,h,1/h,0,h,-1/h,0,-h,1/h,0,-h,-1/h,h,1/h,0,h,-1/h,0,-h,1/h,0,
-h,-1/h,0,1/h,0,h,1/h,0,-h,-1/h,0,h,-1/h,0,-h,1,1,1,1,1,-1,1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,-1],
[0,1,1/h,0,1,-1/h,0,-1,1/h,0,-1,-1/h,1,1/h,0,1,-1/h,0,-1,1/h,0,-1,-1/h,0,1/h,0,1,1/h,0,-1,-1/h,0,1,-1/h,0,-1]]);

xyz01 = List.Transpose(List.Chop(phd01.ValueAtKey(p),3));
pnt01 = Point.ByCoordinates(xyz01[0],xyz01[1],xyz01[2]);
phd02 = Dictionary.ByKeysValues(["Tetrahedron","Hexahedron","Octahedron","Dodecahedron","Icosahedron"],[[3,4],[4,6],[3,8],[5,16],[3,20]]);
pnt02 = List.Combinations(pnt01,phd02.ValueAtKey(p)[0],false);
bln01 = List.AllTrue(pnt02.DoesIntersect(Circle.ByBestFitThroughPoints(pnt02))<1>);
pnt03 = List.FilterByBoolMask(pnt02,bln01)["in"];
rad01 = Math.Round(Circle.ByBestFitThroughPoints(pnt03).Radius,6);
pnt04 = List.GroupByKey(pnt03,rad01);
pnt05 = List.FirstItem(List.SortByKey(pnt04["groups"],pnt04["unique keys"])["sortedList"]);
pln01 = Plane.ByBestFitThroughPoints(pnt05);
dir01 = Vector.ByTwoPoints(pln01.Origin,pnt05);
ang01 = Math.Round(dir01.AngleAboutAxis(pln01.XAxis,pln01.Normal),3);
srf01 = List.SortByKey(pnt05<1>,ang01<1>)["sortedList"];
sld01 = PolySurface.ByJoinedSurfaces(Surface.ByPerimeterPoints(srf01)).ExtractSolids();
```

Only edges are obtained with a slightly altered approach

![Platonic Solid Frame](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MRiIZj0l1W_vCTTrkg5%2F-MRiK9Tlw4Lbqzng0-i1%2Fpolyhedron.gif?alt=media\&token=42ab50d9-3602-456e-8086-0479eb6a4007)

```d
h = (1+Math.Sqrt(5))/2-1;
phd01 = Dictionary.ByKeysValues(["Tetrahedron","Hexahedron","Octahedron","Dodecahedron","Icosahedron"],
[[1,1,1,1,-1,-1,-1,1,-1,-1,-1,1],[1,1,1,1,1,-1,1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,-1],
[0,0,1,0,0,-1,0,1,0,0,-1,0,1,0,0,-1,0,0],[0,h,1/h,0,h,-1/h,0,-h,1/h,0,-h,-1/h,h,1/h,0,h,-1/h,0,-h,1/h,0,
-h,-1/h,0,1/h,0,h,1/h,0,-h,-1/h,0,h,-1/h,0,-h,1,1,1,1,1,-1,1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,-1],
[0,1,1/h,0,1,-1/h,0,-1,1/h,0,-1,-1/h,1,1/h,0,1,-1/h,0,-1,1/h,0,-1,-1/h,0,1/h,0,1,1/h,0,-1,-1/h,0,1,-1/h,0,-1]]);

xyz01 = List.Transpose(List.Chop(phd01.ValueAtKey(p),3));
pnt01 = Point.ByCoordinates(xyz01[0],xyz01[1],xyz01[2]);
pnt02 = List.Combinations(pnt01,2,false);
dst01 = Math.Round(List.FirstItem(pnt02<1>).DistanceTo(List.LastItem(pnt02<1>)),3);
pnt03 = List.SortByKey(pnt02,dst01);
pnt04 = List.GroupByKey(pnt03["sortedList"],pnt03["sortedKeys"])["groups"];
edg01 = Line.ByBestFitThroughPoints(List.FirstItem(pnt04));
```


# Polyline to PolyArc

Convert a series of lines to a series of tangential arcs

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MZM7SZkt5hXIu_8tiT4%2F-MZM8B-7yI76iwntO7iT%2FoffsetPolyLineAsPolyarc.png?alt=media\&token=bfcc7087-ded3-488b-9148-bb4fd6c4da27)

```d
def lnToAr(pl:var[]..[], of:double)
{
	pc1 = List.FirstItem(pl.Curves());
	//First Arc
	ac1 = List.FirstItem(pc1);
	ac2 = ac1.Offset(of).PointAtParameter(0.5);
	ar1 = Arc.ByThreePoints(ac1.StartPoint,ac2,ac1.EndPoint);
	ac3 = List.RestOfItems(pc1);

	ar5 = [Imperative]
	{
		cnt = 1;
		pc2 = [ar1];

		for (cr in ac3)
		{
			pc2[cnt] = Arc.ByStartPointEndPointStartTangent(cr.StartPoint,cr.EndPoint,ar1.TangentAtParameter(1));
			ar1 = pc2[cnt];
			cnt = cnt + 1;
		}
		return pc2;
	}
	return ar5;
```


# Roman Surface

Steiner Surface

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FAXbtVJ0OrGV8LlI0XCUm%2FromanSurface3.gif?alt=media\&token=c0dcb521-dde1-4d51-952c-5512bf0f0834)

```d
rd = 40;
th = 0..360;
ph = -90..90;
x1 = Math.Pow(rd,2) * Math.Cos(th)<2> * Math.Sin(th) * Math.Sin(ph)<1>;
y1 = Math.Pow(rd,2) * Math.Cos(th)<1> * Math.Sin(th) * Math.Cos(ph)<2>;
z1 = Math.Pow(rd,2) * Math.Pow(Math.Cos(th), 2) * Math.Cos(ph)<1> * Math.Sin(ph);
s1 = NurbsSurface.ByPoints(Point.ByCoordinates(x1, y1, z1));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FuVDaD2nz8m5V9V2KEVxl%2FromanSurface_2021-10-10_09-32-09.png?alt=media\&token=e70d1b8b-ffbe-43a3-9dc2-3ca66d708561)

```d
// Tspline Surface
c1 = List.Flatten(List.Flatten(s1.GetIsoline((0..1)<1>,0..1..#33),-1).SplitByParameter(0..1..#33));
t1 = TSplineSurface.BuildPipes(c1, 10, 0.001, null, true,true, null, null, null,null, null, null, false);[GeometryColor.ByGeometryColor(t1,Color.ByARGB(250,20,100,120)),GeometryColor.ByGeometryColor(s1,Color.ByARGB(150,150,150,20))];
```


# Sagrada Familia Schools Roof

Begin with a basic sine wave and incrementally alter lists of points to alter positions and profiles utilizing replication guides in Design Script (ver. 3.1)

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FvGxNTwCpPvU7w5gCSqF0%2FGaudi_2024-01-26_10-16-56.png?alt=media&amp;token=6cbc14c9-c7d6-4f6e-9940-e0bb625c5ac5" alt=""><figcaption><p>Sagrida Familia Schools Roof</p></figcaption></figure>

```d
p = Point.ByCoordinates (Math.DegreesToRadians((0..(180*8)..10)),(-10..10..#9)<1>,(Math.Sin((-90..(180*8)..10)+(0..90..10)<1>)*(-1.25..1.25..#10))<1>);
GeometryColor.ByGeometryColor(NurbsSurface.ByPoints(Point.ByCoordinates (p.X,(p.Z<-0.6 ? p.Y+(-p.Y*(p.Z)*0.08) : p.Y),p.Z)).Thicken(0.25).Translate(0,0,1.5),Color.ByARGB(255,255,250,200));
```

While the code required to create this geometry can be packed into a couple of lines of Design, below is a stepwise elaboration of the process.

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FuqIWBJbPxiy4txJula1z%2F01.png?alt=media&amp;token=babc0fb0-44c4-48f5-8e64-eb242130b8f4" alt=""><figcaption><p>Step 1 : Sine Wave</p></figcaption></figure>

```d
// Sine Wave
r = 0..360;
x = Math.DegreesToRadians(r);
y = 0;
z = Math.Sin(r);
p = Point.ByCoordinates (x,y,z);
```

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FYUEGPKDGJfcgI4rnh2VV%2F02.png?alt=media&amp;token=1935fd24-e32d-4504-8c77-6dc142ed87f0" alt=""><figcaption><p>Step 2 : Decrease the point count, increase the wave frequency and amplitude</p></figcaption></figure>

```d
// Decrease point count
r = 0..360..10;

// Increase Frequency
r = (0..360..10) * 4;

// Increase Amplitude
z = Math.Sin(r) * 1.5;
```

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FVGICrZYXWYvc6gQRWGFU%2F03.png?alt=media&amp;token=8d7c93fc-414e-463a-a2df-9a5e52c75364" alt=""><figcaption><p>Step 3 : Multiple similar waves along the Y-axis</p></figcaption></figure>

```d
// A range of values along the Y-axis
y = -10..10..#9;

// Repeat waves along the Y-axis
p = Point.ByCoordinates (x,y<1>,z);
```

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FISMKNDHf2i0wuqtZJRkb%2F04.png?alt=media&amp;token=d4e09ebc-12fc-4cc5-a821-f0e788e490ae" alt=""><figcaption><p>Step 4 : Nurbs Surface</p></figcaption></figure>

```d
// Nurbs Surface
s = NurbsSurface.ByPoints(p);
```

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2Ft9eO4gG1Khpfa2lccb4K%2F05.png?alt=media&amp;token=b3b14f83-8b9e-405d-a12c-7b364db67503" alt=""><figcaption><p>Step 5 : Crest (from trough) at start of last wave</p></figcaption></figure>

```d
// Increase Z incrementally
z = Math.Sin(r +(0..90..#9)<1>) * 1.5;

// Apply to wave profiles
p = Point.ByCoordinates (x,y<1>,z<1>);
```

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FH966xHMjx1Ux13271hvX%2F06.png?alt=media&amp;token=794c9acf-8ad0-49eb-9501-12799f9bfec5" alt=""><figcaption><p>Step 6 : Flattening amplitude towards the middle</p></figcaption></figure>

```d
// Incrementally minimizing amplitude of waves towards the middle
a = List.Flatten([1.5..0..#4,0,0..1.5..#4],-1);
z = Math.Sin(r +(0..90..#9)<1>) * a;
```

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FdTNj4oza6gj9Csdw5f5u%2F07.png?alt=media&amp;token=58ddc918-f370-4b6f-a91d-2d8cf384709a" alt=""><figcaption><p>Step 7 : Trough Protrusion</p></figcaption></figure>

```d
// Trough Protrusion
tp = p.Z < -1.4 ? p.Y+(-p.Y*(p.Z)*0.1) : p.Y;
pp = Point.ByCoordinates(p.X,tp,p.Z);
```

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FFp8fKDuNt8heI8yU4Y99%2F08.png?alt=media&amp;token=5de3630e-fb39-40cd-8aef-cd596d67f146" alt=""><figcaption><p>Step 8 : Thicken</p></figcaption></figure>

```d
// Sine Wave
r = (0..360..10) * 4;
x = Math.DegreesToRadians(r);
y = -10..10..#9;
a = List.Flatten([1.5..0..#4,0,0..1.5..#4],-1);
z = Math.Sin(r +(0..90..#9)<1>) * a;
p = Point.ByCoordinates (x,y<1>,z<1>);

// Trough Protrusion
tp = p.Z<-1.4 ? p.Y+(-p.Y*(p.Z)*0.1) : p.Y;
pp = Point.ByCoordinates(p.X,tp,p.Z);

// Nurbs Surface
s = NurbsSurface.ByPoints(pp).Thicken(0.25);
```


# Sine Curve

Sine Curve from equations

![Diminishing amplitude Sine Curve](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvEMn3U5MBfufO2Ci0%2Fsine1.png?alt=media\&token=52d97814-6134-4d60-aebf-8807160412c9)

```d
n = 500;
w = 10;
h = 4;
x = 0..Math.PI*2*10..#n;
y = Math.Sin(0..360*w..#n) * (h..0.1..#n);
p = Point.ByCoordinates(x,y);
c = NurbsCurve.ByPoints(p);
```

![Diminishing amplitude Sine Curve along Base Curve](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvFiZWYEYCq9wmwFy3%2Fsine3.png?alt=media\&token=401f78f6-534c-4d9a-aa05-a21ddaa7852d)

```d
//Base Curve
c1 = NurbsCurve.ByPoints
(Point.ByCoordinates([0,10,50],[0,10,0]));
//Number of Divisions
n = 500;
//Scale Wave Extent
w = 10;
//Scale Wave Height
h = 5;
//Points on Curve
p1 = c1.PointAtParameter(0..1..#n);
//Normal at Points
n1 = c1.NormalAtParameter(0..1..#n);
//Scale wrt Base Curve Length
s = c1.Length/(Math.PiTimes2*w);
y = Math.Sin(0..360*w..#n) * (h..0.1..#n) * s;
p2 = p1.Translate(n1,y);
//Nurbs Curve
c2 = NurbsCurve.ByPoints(p2);
```

![Diminishing amplitude Sine Curve along Base Curve with Attractor](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvDxI0xh9ek5fwkJj2%2FsineCurve_2020-12-18_10-59-12.png?alt=media\&token=e79cbcb5-91c0-4d9b-a2e8-e83805fc1b68)

```d
//Number of Points
ct = 200;

//Amplitude Scale
as = 2;

//Period Scale
ps = 8;

//Base Curve
bc = NurbsCurve.ByControlPoints(Point.ByCoordinates([0,10,40,50],[0,20,20,0]));
cp = bc.PointAtParameter(0..1..#ct);
cn = bc.NormalAtParameter(0..1..#ct);

//Sine Curve
ds = Math.Sin(0..360*ps..#ct)*2;
ic = Math.RemapRange(at.DistanceTo(cp),as,0);
nc = NurbsCurve.ByPoints(cp.Translate(cn,ds*Math.Pow(ic,2)));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvAFkS9lSxDP0RviFO%2F-MOvE1TrZBkykjoNyW4l%2Fsine.gif?alt=media\&token=e6957687-0663-4b25-af30-48441317740c)


# Sine Ribbon

Create a form using an equation to modify the form of a sine wave

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2Fvmqk0YtpGte2ExeyjZXn%2FsineRibbon.png?alt=media&amp;token=ec59d2ab-0e8b-4681-a105-fcbf06886db3" alt=""><figcaption><p>Sine Ribbon</p></figcaption></figure>

```d
n = 6;
u = 0..(90*n)..#(50*n);
v = 0..(180*n)..#(50*n);

x = (Math.DegreesToRadians(u))*2;
y = (Math.Sin(u)*Math.Cos(u))*2;
z = Math.Pow(Math.Sin(v),4);

c = NurbsCurve.ByPoints(Point.ByCoordinates(x,y,z));

d = c.Mirror(Plane.XY()).Mirror(Plane.XZ()).Translate(0,0,2);

e = Surface.ByLoft([c,d]).Thicken(0.1)
```


# Spherical Transformations

Transforming with equations

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLyFP3rAPFAfw0YfRG%2F-LhLzMSiGur6B8K7LQuh%2Fsphere.gif?alt=media\&token=f745feb0-f24c-4df6-854e-0bd6613d5a7a)

{% file src="/files/-Lh9HMZ1qSjhYX98y-yG" %}

```d
//Spherical Transformations 

n = 11;
x = Math.Sin(0..180..#n)<1>*Math.Cos(0..360..#n);
y = Math.Sin(0..180..#n)<1>*Math.Sin(0..360..#n);
z = Math.Cos(0..180..#n);

//Sphere
p1 = Point.ByCoordinates(x<1>,y<1>,z<1><2>);

//Sphere Translated and Scaled along Z-Axis
p2 = Point.ByCoordinates(x<1>,y<1>,((0.75+z)/(1.75..2..#n))<1><2>);

//Sphere Translated and Scaled along X-Axis
p3 = Point.ByCoordinates(((x+0.75)*(1..3..#n))<1>,y<1>,z<1><2>);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzocI5pG3xZndglbmD%2F-Lfzp0Ib_boXt6-Xg6cI%2FsphericalShapes.png?alt=media\&token=c576eabf-f235-4181-b767-bd8267898ffc)

Dome Transformations

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LlGeI-VuwbWUU6x1tyX%2F-LlGg21D6bIoqoXqBveh%2Fdome.gif?alt=media\&token=2448dd91-0bc0-43c4-b79f-0dd76a62331f)

```d
//Dome Transformations

n = 11;
x = Math.Sin(0..90..#n)<1>*Math.Cos(0..360..#n);
y = Math.Sin(0..90..#n)<1>*Math.Sin(0..360..#n);
z = Math.Cos(0..90..#n);

//Dome
p1 = Point.ByCoordinates((x*(mnx..(mnx+mxs)..#n))<1>,
y<1>,(z/(mnz..(mnz+mxz)..#n))<1><2>);
```

![Asymmetric Vertical Scaling](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MM-gfiRaCkn7z4a326y%2F-MM-hFvRUpxbdNCQ-RbM%2FasymmetrictransformationSphere.png?alt=media\&token=d2befbe3-dc25-49c6-828e-34db8128cdac)

```d
u = 0..360..#50;
v = 0..180..#50;
x = (Math.Cos(u) * Math.Sin(v)<1>) * 1.25;
y = (Math.Sin(u) * Math.Sin(v)<1>) * 1.65;
z = Math.Pow(Math.Cos(0..55..#50),8)*-2+2;

NurbsSurface.ByPoints(Point.ByCoordinates(x,y,z));
```


# Split Rectangle

Split rectangle by specifying number of divisions, minimum and maximum area

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzzFHJyUlZ04gLc_z6%2F-LfzzPxMrFXc3zIs2Y7j%2FsplitRect.png?alt=media\&token=93f418db-3daf-46b6-926c-56d55df14a5d)

{% file src="/files/-LfzzUVYPtnbW0eY3ZGq" %}

```d
rctg1 = Rectangle.ByWidthLength(10,10);
//Number of Lines
cnt;
//Minimum Area of Polygon
min;
//Maximum Area of Polygon
max;
//Max attempts
atm = 500;

[Imperative]
{
	surf1 = rctg1.Patch();
	lins1 = [];
	c = 0;
	t = [];
	sed = 0;
	test1 = true;
	sed = sed + 1;
	while(test1 && sed<atm)
	{
		lins1 = lins(rctg1,cnt,sed);
		surf1 = spl(rctg1,lins1);
		for (s in surf1)
		{
			if (s.Area<min || s.Area>max)
			{
				t[c] = true;
				c = c + 1;
			}
			else
			{
				t[c] = false;
				c = c + 1;
			}
		}
		sed = sed + 1;
		test1 = List.Contains(t,true);
	}
	return surf1;
};

//Functions
def lins(rec,cnt,sed)
{
	edgs1 = rec.Explode();
	parm1 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed)*50)),cnt/2);
	parm2 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed+1)*50)),cnt/2);
	parm3 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed+2)*50)),cnt/2);
	parm4 = List.TakeItems(List.Shuffle(0.1..1..#(Math.Random(sed+3)*50)),cnt/2);
	pnts1 = edgs1[0].PointAtParameter(parm1);
	pnts2 = edgs1[1].PointAtParameter(parm2);
	pnts3 = edgs1[2].PointAtParameter(parm3);
	pnts4 = edgs1[3].PointAtParameter(parm4);
	lins1 = List.TakeItems(List.Flatten(Line.ByStartPointEndPoint([pnts1,pnts2],[pnts3,pnts4]),-1),cnt);
	return lins1;
};


def spl(rect,lines:var[]..[])
{
//Cutting Tool
tool = Solid.ByUnion(List.Flatten([rect,lines],-1).Extrude(Vector.ZAxis()).Thicken(0.4));

//Divisions
divisions = List.Clean(PolyCurve.ByJoinedCurves(rect.Patch().Split(tool).PerimeterCurves()),false).Offset(0.2,false).Patch();
return divisions;
};
```


# Tangential Circle through Point

Circle passing through a point and tangential to two curves

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MGi86lceXptFSMiVA2f%2F-MGi8U3hq9FX9mKONwwx%2FtanPntArc_2020-09-08_07-07-13.png?alt=media\&token=d7a6b25d-8419-4b6a-8afd-e4d86a73b88f)

```d
//Increase num for higher precision
//Will fail if too low and take too long if too high
num = 15;

//Centers of circles that are tangential and equidistant to the input Curves
pt1 = c1.PointAtParameter(0..1..#num);
pt2 = c2.PointAtParameter(0..1..#num);
pl1 = Plane.ByThreePoints(c1.CenterPoint,c1.CenterPoint.Translate(0,0,1),pt1);
vc1 = Vector.ByTwoPoints(c2.CenterPoint,pt2);
pt3 = Point.PruneDuplicates(List.Flatten(pt2.Project(pl1<1>,vc1<2>),-1),0.01);
ds1 = Math.Round(pt3<1>.DistanceTo(pt1<2>),1);
ds2 = Math.Round(pt3<1>.DistanceTo(pt2<2>),1);
pt4 = List.FilterByBoolMask(pt3,List.AllFalse((ds1==ds2)<1>))["out"];

//Centers that are equidistant to the input Curves and Point
ds3 = Math.Round(pt4<1>.DistanceTo(c1<2>),1);
ds4 = Math.Round(pt4<1>.DistanceTo(c2<2>),1);
ds5 = Math.Round(pt4<1>.DistanceTo(p1<2>),1);
pt5 = List.FilterByBoolMask(pt4,ds3==ds5 && ds4==ds5)["in"];
ds6 = pt5.DistanceTo(p1);
cr1 = Circle.ByCenterPointRadius(pt5,ds6);

//Geometry Color
[GeometryColor.ByGeometryColor(p1,Color.ByARGB(255,255,0,0)),
GeometryColor.ByGeometryColor(c1,Color.ByARGB(255,0,255,0)),
GeometryColor.ByGeometryColor(c2,Color.ByARGB(255,0,0,255)),
GeometryColor.ByGeometryColor(cr1[0],Color.ByARGB(255,255,0,255))];
```

{% file src="/files/-MGi8atfvLOnBQGa3\_32" %}

```d
//Curve 1
c1 = Arc.ByThreePoints(Point.ByCoordinates(-3,2),
Point.ByCoordinates(2,1),Point.ByCoordinates(5,3));

// Curve 2
c2 = Arc.ByThreePoints(Point.ByCoordinates(-6,2),
Point.ByCoordinates(-4,1),Point.ByCoordinates(0,3));

//Point
p1 = Point.ByCoordinates(-2,1);

//Limit length of arcs as much as possible
//Will fail if no circle passes through the point
//Multiple circles that satisfy the condition possible
```


# Travelling Salesman Problem

Connecting a list of points without self intersections

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MkbuxRulpgJtdGbbGfp%2F-MkbvHdrBbAD1zAjBipP%2FtravellingSalesmanProblem_2021-09-27_09-04-53.png?alt=media\&token=5da2622a-022a-45af-9d46-2c83f201603f)

```d
// Check for Self Intersection
def pgnInt (pts:var[]..[],pnt:var)
{
	//Edges with existing points
	pg01 = Polygon.ByPoints(pts).Explode();
	in01 = 1..List.Count(pg01);
	//Distance to New point
	ds01 = pnt.DistanceTo(pg01);
	//Index of closest edge to new point
	in02 = List.SortByKey(in01,ds01)["sortedList"];
	//Shift indices of points list
	pt01 = List.ShiftIndices(pts,List.FirstItem(-in02));


	return [Imperative]
	{
		bl01 = true;
		n = 0;
		pt11 = [];

		while (bl01)
		{
			// Shift insertion index
			pt10 = List.ShiftIndices(pt01,n);
			//Add new point to top of list
			pt11 = List.AddItemToFront(pnt,pt10);
			pg11 = Polygon.ByPoints(pt11);
			//Check Self Intersection
			it11 = pg11.SelfIntersections();
			n = n + 1;
			bl01 = List.Count(it11) != 0;
		}
		return pt11;
	}
};

// Add Closest Neighbour
def clsNgh (pnt:var[]..[])
{
	occ = pnt[0];
	avl = pnt[1];
	pg01 = Polygon.ByPoints(occ);
	ds01 = pg01.DistanceTo(avl);
	pt01 = List.SortByKey(avl,ds01)["sortedList"];
	pt02 = List.FirstItem(pt01);
	pt03 = List.RestOfItems(pt01);
	pt04 = pgnInt (occ,pt02);
	return [pt04,pt03];
};

// Repeat until all points are included
def tsp (pt01:var[]..[])
{
	ds01 = List.FirstItem(pt01).DistanceTo(pt01);
	pt02 = List.SortByKey(pt01,ds01)["sortedList"];
	pt11 = [List.TakeItems(pt02,3),List.DropItems(pt02,3)];
	return [Imperative]
	{
		a = [];
		c = List.Count(pt11[1]);
		while (c > 0)
		{
			a = clsNgh (pt11);
			pt11 = a;
			c = c - 1;
		}
		return a[0];
};
};


// Implementation on lists of Random points
n = [25,50,75,100];

pt01 = Point.ByCoordinates
(Math.RandomList(n)*8000,Math.RandomList(n)*6000);

pt02 =tsp(pt01<1>);
[pt02[0],GeometryColor.ByGeometryColor
(Polygon.ByPoints(pt02[0]),Color.ByARGB(255,255,0,0))];
[pt02[1],GeometryColor.ByGeometryColor
(Polygon.ByPoints(pt02[1]),Color.ByARGB(255,0,255,0))];
[pt02[2],GeometryColor.ByGeometryColor
(Polygon.ByPoints(pt02[2]),Color.ByARGB(255,0,0,255))];
[pt02[3],GeometryColor.ByGeometryColor
(Polygon.ByPoints(pt02[3]),Color.ByARGB(255,255,0,250))];
```


# Unaligned Bounding Box

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MFlOrNWdm4KH8d_ieVa%2F-MFlPKTMVJM0CskCD4j-%2FunAlignedBoundingBox.png?alt=media\&token=85f8bb55-6a85-4ac4-a812-30a86615964b)

```d
def UnalignedBoundingBox(gmty:var[]..[],coSy:var[]..[])
{
	coSy1 = CoordinateSystem.Identity().Transform(coSy);
	gmBb1 = BoundingBox.ByGeometry(gmty.Transform(coSy1,CoordinateSystem.Identity())<1>);
	gmBb2 = Math.Round(gmBb1.MinPoint.DistanceTo(gmBb1.MaxPoint),3);
	gmBb3 = DSCore.List.FirstItem(DSCore.List.SortByKey(gmBb1,gmBb2)["sorted list"]).ToCuboid();
	coSy2 = DSCore.List.FirstItem(DSCore.List.SortByKey(coSy1,gmBb2)["sorted list"]);
	return gmBb3.Transform(CoordinateSystem.Identity(),coSy2);
};
```

{% file src="/files/-MFlPVD\_89chJ-kuI\_\_g" %}
Dynamo Version 2.9
{% endfile %}


# Alter by Boolean Sequence

Chop list at indices where there is a change in value

![Sequentially number true blocks](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FpOBxu4YxK8fXl8901lDj%2FsqnNum.png?alt=media\&token=a15191dd-8b29-42d9-ad10-b058abc4c756)

```d
def numTruSqn (lst01:var[]..[])
{
	//Seperate consecutive true and false
	cns01 = List.DropItems(lst01,1) == List.DropItems(lst01,-1);
	cns02 = List.Flatten([-1, List.AllIndicesOf(cns01,false),List.Count(lst01)-1], -1);
	cns03 = List.DropItems(cns02,1) - List.DropItems(cns02,-1);
	lst02 = List.Chop(lst01,cns03);

	// Assign value to true
	lst03 = List.Flatten(List.UniqueItems(lst02<1>));
	lst04 = Math.Sum(List.TakeItems(lst03 == true ? 1 : 0, 1..List.Count(lst03)));
	return lst02 == true ? lst04 : 0;
};
```

![Replace trues sequentially with elements from another list](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSkHaEAFDe1WYBWogEk%2F-MSkIQU5NFBeW87g3G1Z%2FreplaceTrue_2021-01-29_11-45-59.png?alt=media\&token=d3756d60-74c4-4677-9c24-43eea411417e)

```d
ls1 = List.Flatten(lst1,-1);
ls2 = List.GroupByKey(0..(List.Count(ls1)-1),ls1);
ls3 = List.SortByKey(ls2["groups"],ls2["unique keys"])["sortedList"];
ls4 = [List.OfRepeatedItem(null,List.CountFalse(ls1)),lst2];
ls5 = List.SortByKey(List.Flatten(ls4,-1),List.Flatten(ls3,-1));
ls6 = List.Chop(ls5["sortedList"],List.Count(lst1<1>));
```

![List chopped to correspond with true/false sequence](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MMy0QNCdCm_NMmxwoBO%2F-MMy2Mfml6G4A9b5tDcp%2FchopByBooleanList_2020-11-25_11-47-39.png?alt=media\&token=574855d1-0ad8-4aa6-a743-63246b160214)

```d
bln2 = List.Sublists(bln1,0..1,1);
bln3 = List.AllTrue(bln2<1>) ? false
:List.LastItem(bln2<1>) == true ? true
:List.FirstItem(bln2<1>) == true ? true
:false;
ind0 = List.AllIndicesOf(bln3,true)+1;
ind1 = List.Flatten([0,ind0,List.Count(bln1)],-1);
ind2 = List.RestOfItems(ind1)-List.DropItems(ind1,-1);
lst1 = List.Chop(lst,ind2);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MMy0QNCdCm_NMmxwoBO%2F-MMy47pp7vDBxZcx1Hlx%2FchopByBooleanList_2020-11-25_11-55-08.png?alt=media\&token=03ee966d-c771-46a2-a0c6-5ecabc3ef842)

![Variation in which the first item varies from the rest](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MMy0QNCdCm_NMmxwoBO%2F-MMy31ixiFiRUzaacuQ3%2FchopByBoolSeq_2020-11-25_09-53-19.png?alt=media\&token=938cb461-9af6-49bd-bbb9-e072c55f1e6b)

```d
bln2 = List.Sublists(bln1,0..1,1);
bln3 = List.AllFalse(bln2<1>) ? false
: List.LastItem(bln2<1>) == true ? true
: List.FirstItem(bln2<1>) == true ? false
: true;
ind0 = List.AllIndicesOf(bln3,false)+1;
ind1 = List.Flatten([0,ind0,List.Count(bln1)],-1);
ind2 = List.RestOfItems(ind1)-List.DropItems(ind1,-1);
lst1 = List.Chop(lst,ind2);
```


# Color by distance

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLOp7q1AeHcCA6v9Cz%2F-LhLP0H8NWOFk8UeB9uR%2Fcrane.jpg?alt=media\&token=82024eba-2e3c-44c9-9b65-4c97e73ffc61)

{% file src="/files/-LhLP\_rfXf4\_Wt6xo6x-" %}

```d
l1=(Line.ByStartPointEndPoint((elm.BoundingBox).MaxPoint,
(elm.BoundingBox).MinPoint)).PointAtParameter(0.5);
crnBb=BoundingBox.ByGeometry(crn.Geometry());
crnCp=(Line.ByStartPointEndPoint(crnBb.MaxPoint,
crnBb.MinPoint)).PointAtParameter(0.5);
l2=Line.ByStartPointEndPoint(Point.ByCoordinates
(crnCp.X,crnCp.Y,crnBb.MinPoint.Z),Point.ByCoordinates
(crnCp.X,crnCp.Y,crnBb.MaxPoint.Z));

//max and min distances of each distance group
d1=Flatten(l1<1>.DistanceTo(l2));
d2=List.MinimumItem(d1)..List.MaximumItem(d1)..~inc;

i1=List.DropItems(d2,-1);
i2=List.DropItems(d2,1);

//Filteration criteria
b1=List.Flatten(d1>i1<1><2>,1);
b2=List.Flatten(d1<=(i2+100)<1><2>,1);
b1&&b2;

//Sorting elements into groups
g1=List.FilterByBoolMask(elm,(b1&&b2)<1>);
g2=List.GetItemAtIndex(g1<1>,0);

//Colors
c=List.TakeItems(Transpose(col)[1],List.Count(d2)-1);

//Override color in Revit view
g=g2<1><2>.OverrideColorInView(c<1>);

//Legend
lg1=Math.Round(i1,1);
lg2=Math.Round(i2,1);
lg3=List.TakeItems(Transpose(col)[0],List.Count(d2)-1);
lg=[lg1,lg2,lg3];

lg1+" to "+lg2+" ["+lg3+"]";
```

```d
[["Red",Color.ByARGB(255,255,0,0)],
["Green",Color.ByARGB(255,0,255,0)],
["Blue",Color.ByARGB(255,0,0,255)],
["Yellow",Color.ByARGB(255,255,255,0)],
["Cyan",Color.ByARGB(255,0,255,255)],
["Magenta",Color.ByARGB(255,255,0,255)],
["Violet",Color.ByARGB(255,238,130,238)],
["Orange",Color.ByARGB(255,255,165,0)],
["Brown",Color.ByARGB(255,165,42,42)],
["Gray",Color.ByARGB(255,128,128,128)]];
```

{% file src="/files/-LhLPX5F-TA\_RFl28EB\_" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLOp7q1AeHcCA6v9Cz%2F-LhLP28n_lzIgdvIfWo5%2Fcrane1.jpg?alt=media\&token=b85b8081-b626-48d4-a069-d2324ca4ba5b)


# Consecutive Points

Closest subsequent point in sequence

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MGig2qw4WChC1Aspqzx%2F-MGigRmhD_eQS0SYWv28%2FclosestPointsSequence_2020-09-08_10-14-58.png?alt=media\&token=57daf44a-2361-4099-8e68-bead221a56df)

{% file src="/files/-MGigbyfvFPMwaqzXVju" %}
Dynamo 2.9
{% endfile %}

```d
def ClosestPointsSequence (stPt, pnts:var[]..[])
{
	return = [Imperative]
	{
		cnt1 = List.Count (pnts);
		pnt1 = pnts;
		pnt2 = [stPt];

		while (List.Count(pnt2)<cnt1)
		{
			pnt3 = List.SetDifference(pnt1,pnt2);
			pnt4 = List.LastItem(pnt2);
			dis1 = pnt4.DistanceTo(pnt3);
			pnt5 = List.SortByKey(pnt3,dis1)["sorted list"];
			pnt1 = List.RestOfItems(pnt5);
			pnt2 = List.AddItemToEnd(List.FirstItem(pnt5),pnt2);
		}

		return pnt2;
	}
};
```

This can be extended to obtain the shortest path connecting a list of points by obtaining sequences with all possible start points and then calculating the length of the connecting poly line

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MHCmX6xzJ3z0YOwBzIg%2F-MHCn_OR3YdZN4YvuWrY%2FshortestPathConnectingPoints_2020-09-14_07-48-45.png?alt=media\&token=e989d453-127a-4657-8b40-faf4d87e80ba)

{% file src="/files/-MHCnm7qOMKPs3VWP4ZJ" %}
Dynamo 2.9
{% endfile %}


# Distancing

Occupying seats while maintaining minimum separation distance

![Social Distancing](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MLhuVG884TWqW4uUB_6%2F-MLhv3E2ILIlXJTOfgXk%2Fdistancing.gif?alt=media\&token=11efde16-cd7c-4c3a-99ef-1559f5818293)

```d
def TooClose (elm:var[]..[],min)
{
	pnt1 = List.FirstItem(elm.GetLocation());
	elm2 = List.RestOfItems(elm);
	pnt2 = elm2.GetLocation();
	bln1 = pnt1.DistanceTo(pnt2) < min;
	elm3 = List.FilterByBoolMask(elm2,bln1)["out"];
	return elm3;
};

def Distancing (elm:var[]..[],min)
{
	return = [Imperative]
	{
		if (List.Count(elm)>1)
		{
			elm1 = [List.FirstItem(elm)];
			c = 1;
			while (List.Count(elm) > 1)
			{
				elm2 = TooClose (elm,min);
				elm1[c] = List.FirstItem(elm2);
				elm = elm2;
				c = c + 1;
			}
			return elm1;
		}
		else
		{
			return elm;
		}
	}
};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MLhuVG884TWqW4uUB_6%2F-MLhvSprY0Z2OOHNdpjL%2Fdistancing_2020-11-09_09-53-28.png?alt=media\&token=7b5e9f3a-bd60-4459-9090-a1f33f8bba37)

{% file src="/files/-MLhvYVwC4qhtxuhbtkv" %}
Dynamo 2.8
{% endfile %}


# Divide Equally

Sort a list of random numbers into three lists of similar sum

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLKeaxG3gSolSHSZ5H%2F-LhLKme_1zK2x2j5gNwy%2F3bowls.png?alt=media\&token=a2930ffe-b254-4719-b518-fd2446191e0a)

{% file src="/files/-LhLKunIlvSgMWsRnlCy" %}

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


# Geometry from Image

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh9EECxTP007WtieUZy%2F-Lh9Elfm_t-ewmYoypM_%2FImgTrace.png?alt=media\&token=4aed53cc-8371-4438-9612-cb4b325125ee)

{% file src="/files/-Lh9F17PVmfYqBB1xk3h" %}

```d
pntSeq(grpPnts(pts));

	// Group Contiguous Points
	def grpPnts(pts:var[]..[])
    {
    	dis1 = pts<1>.DistanceTo(pts<2>)<2;
    	ind1 = List.AllIndicesOf(dis1<1>,true);
    	bln1 = true;
    	ind2 = [Imperative]
    	{
    		while (bln1)
    		{
    			cnt1 = List.Count(ind1);
    			ind1 = grpIndx(ind1);
    			cnt2 = List.Count(ind1);
    			bln1 = cnt2!=cnt1;
    		}
    		return = ind1;
    	}
    	pts1 = List.GetItemAtIndex(pts,ind2);
    	return = pts1;
    };

    def grpIndx(ind:var[]..[])
    {
    	ind1 = List.SetIntersection(ind<1>,ind<2>);
    	cnt1 = List.Count(ind1<1><2>)>0;
    	ind2 = List.FilterByBoolMask(ind,cnt1<1>)["in"];
    	ind3 = List.UniqueItems(List.Flatten(ind2<1>,-1)<1>);
    	ind4 = List.UniqueItems(List.Sort(ind3<1>));
    	return = ind4;
    };

    def pntSeq(pnt:var[]..[])
	{
		c = Point.ByCoordinates(Math.Sum(pnt.X)/List.Count(pnt<1>),
		Math.Sum(pnt.Y)/List.Count(pnt<1>));
		a = (Vector.ByTwoPoints(c,pnt).Normalized()).AngleAboutAxis
		(Vector.XAxis(),Vector.ZAxis());
		p = List.SortByKey(pnt<1>,a<1>)["sorted list"];
		return p;

	};
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh9EECxTP007WtieUZy%2F-Lh9EsOBRI2OO3VXS9RS%2FimgTrcSmpl.png?alt=media\&token=4779d6e9-c9a2-44e0-a615-5938800a958d)


# Image based Point Density

Higher concentration at darker colors

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MMoEXcAUmITDFvpsfhp%2F-MMoRREPc0dG4XQgV3DZ%2Fperf_2020-11-23_03-00-53.png?alt=media\&token=be7fa813-285b-4fc4-a87e-ee5838e9719c)

```d
img01 = Image.ReadFromFile(img00);
dim01 = Image.Dimensions(img01);
wdt01 = dim01["width"]/25;
hgt01 = dim01["height"]/25;
pxl01 = Image.Pixels(img01,wdt01,hgt01);
bgt01 = Color.Brightness(pxl01);
pnt01 = Point.ByCoordinates((0..wdt01-1)<1>,(0..hgt01-1)<2>);
bgt02 = List.FilterByBoolMask(bgt01,bgt01 > 0.5);
bgt11 = List.TakeEveryNthItem(bgt02["in"]<1>,2,0);
rad01 = List.TakeEveryNthItem(bgt11,2,0) * 0.5;
pnt02 = List.FilterByBoolMask(pnt01,bgt01 > 0.5);
pnt11 = List.TakeEveryNthItem(pnt02["in"]<1>,2,0);
cen01 = List.TakeEveryNthItem(pnt11,2,0);
rad02 = (Math.Floor(bgt02["out"])+0.1)*1.75;
cir01 = Circle.ByCenterPointRadius(cen01,rad01);
cir02 = Circle.ByCenterPointRadius(pnt02["out"],rad02);
[cir01,cir02];
```


# Isovists

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLR34brSTcWIdxY4IX%2F-LhLRmGmPjIjn_A4lQW2%2Fisovists-1.png?alt=media\&token=11b9da6b-6705-4a7b-b130-5ab476889800)

{% file src="/files/-LhLRqgv6hcZWJiRINwf" %}

```d
point1 = Point.ByCoordinates([10, 5, 10], [3, 0, -5]);
t5 = 25;
circle1 = Circle.ByCenterPointRadius(point1, t5);
t4 = [Rectangle.ByWidthLength(60, 30), Rectangle.ByWidthLength(10, 5).Translate(20, 10, 0), Rectangle.ByWidthLength(10, 5).Translate(20, -10, 0), Circle.ByCenterPointRadius(Point.ByCoordinates(-7, -10), 3), NurbsCurve.ByControlPoints(Point.ByCoordinates([-20, -18, 15, -25, 5], [-5, 10, 7, 5, -5]), 3, true)];
t6 = List.AddItemToEnd(circle1@L1<1>, t4);
t7 = (0..1..0.001);
point2 = Curve.PointAtParameter(circle1<1>, t7<2>);
vector1 = Vector.ByTwoPoints(point1, point2);
geometry1 = Point.Project(point1<1L>, t6@@L1<1L>, vector1<1L>);
t8 = List.Transpose(geometry1<1L>);
t9 = List.Flatten(t8@@L3<1L>, -1);
t10 = Geometry.DistanceTo(t9, point1);
t11 = List.SortByKey(t9@@L2<1L>, t10@L2<1L>);
t12 = Dictionary.ValueAtKey(t11, "sorted list");
t13 = Dictionary.ValueAtKey(t11, "sorted keys");
t14 = List.FirstItem(t12@@L2<1L>);
polyCurve1 = PolyCurve.ByPoints(t14, false);
surface1 = Surface.ByPatch(polyCurve1);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLR34brSTcWIdxY4IX%2F-LhLR9QFs750F--Y4M3f%2Fisovist.png?alt=media\&token=826563ad-9a19-4948-bd78-7c37964339e2)


# Reduce Color Palette

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzsBpj7J8vnOOn7MXd%2F-Lfzt0B6Yzlqd2gMykiM%2Fimg-gtry-red.png?alt=media\&token=e429e783-cc77-467e-909a-8fa2daa0dd84)

{% file src="/files/-Lfzt7icCxvlhpjpJ-fQ" %}

```d
imgDim = Image.Dimensions(img);
pxlWdt = imgDim["width"]/10;
pxlHgt = imgDim["height"]/10;

pxlClr = Image.Pixels(img,pxlWdt,pxlHgt);
r1 = [0,255,0,0,255];
g1 = [0,0,255,0,255];
b1 = [0,0,0,255,255];
c1 = Color.ByARGB(255,r1,g1,b1);
r2 = pxlClr.Red;
g2 = pxlClr.Green;
b2 = pxlClr.Blue;
k1 = Math.Sqrt(Math.Pow((r1-r2<1><2>),2)
+Math.Pow((g1-g2<1><2>),2)+
Math.Pow((b1-b2<1><2>),2));
c2 = List.SortByKey(c1,k1<1><2>)["sorted list"];
c3 = List.FirstItem(c2<1><2>);
i2 = Image.FromPixels(c3);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfzsBpj7J8vnOOn7MXd%2F-LfzsJZ5fgp9pCujb9lP%2FReduceColorPalette.jpeg?alt=media\&token=e462a109-1d25-413b-8e31-9c34d5c8f4d8)

{% file src="/files/-LfztG8FsCghO2O-AeDQ" %}


# Replace Consecutive

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lfzu1l2mDAoFD-C_pD0%2F-LfzuL3TSb64Sk_rxZEY%2FreplAltRep.png?alt=media\&token=4b72374b-cf17-464c-81ca-c1845b4b0023)

{% file src="/files/-LfzuQ7kXpmATYcBLBow" %}

```d
a = "";
b = "landing";
c = [[a,a,b,a],[a,b,b,b,a,b],[b,b,b,b,b]];

d = List.Sublists(c<1>,(0..1),1);
e = List.Contains(d<1><2><3>,b);
f = List.AllTrue(e<1><2>);
g = List.AllIndicesOf(f<1>,true);
i = List.TakeEveryNthItem(g<1>,2,0);
j = List.SetDifference(0..List.Count(c<1>)-1,i);
k = List.Cycle(a,List.Count(i<1>));
l = List.GetItemAtIndex(c<1>,j<1>);
m = List.Flatten(List.Transpose([l,k])<1>,-1);
n = List.Flatten(List.Transpose([j,i])<1>,-1);
o = List.SortByKey(m<1>,n<1>)["sorted list"];
```


# Replace Multiple

Replace at a number of indices, a corresponding number of items

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MOvHqd3jIszhAOS-ocF%2F-MOvITG-fjDIQlwlyHWq%2FreplaceMultiple_2020-12-17_05-53-40.png?alt=media\&token=a5e084b3-b4df-4ef7-ac9e-a2ad9ca21bb4)

```d
ind1 = 0..List.Count(lst0)-1;
ind2 = List.SetDifference(ind1,ind0);
ind3 = List.Flatten([ind2,ind0],-1);
bln1 = List.Contains(ind0,ind1<1>);
lst1 = List.FilterByBoolMask(lst0,bln1);
lst2 = List.Flatten([lst1["out"],rep0],-1);
lst3 = List.SortByKey(lst2,ind3)["sortedList"];
```


# Replace Recurring

Replace recurring item with count

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lg--KT4peegk3yxJhXM%2F-Lg--_2C8z2X5r6NPBmb%2FreplaceAndCount.png?alt=media\&token=fe666e5f-ebca-48fc-bae9-5205570cc5e8)

```d
def rep(a:var[])
{
	return = [Imperative]
	{
		b = 0;
		c = [];
		e = 1;
		for(d in a)
		{
			if(d == "unoccupied")
			{
				c[b] = String.PadLeft(e+"",2,"0");
				b = b+1;
				e = e + 1;
			}
			else
			{
				c[b] = d;
				b = b + 1;
			}
		}
		return c;
	}
};
```


# Shadow Area

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLU945-f4jK21n3TiY%2F-LhLUFYW8LSvkf9aY1CZ%2FshadowArea.jpg?alt=media\&token=c934469c-2e1e-4ab3-88e4-8db6c995f196)

{% file src="/files/-LhLULwf76hYvlDzh4Cu" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLU945-f4jK21n3TiY%2F-LhLUP_EHDqJhvgsHWPP%2FShadowArea.png?alt=media\&token=86dcf149-5cbb-4bf1-b2a3-b34557c966fd)


# Shortest Path

Shortest path from one point to another

![Shortest path from one point to another minimizing bends along a grid of curves](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LsN6-K-qXi07e9Cytyw%2F-LsN6JnRG1o5TR8MgIgP%2FshrtPth-20191029_2019-10-29_08-32-28.png?alt=media\&token=5006fbe8-f3cb-4a17-8252-e327f913ff52)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LsN6-K-qXi07e9Cytyw%2F-LsN6EbDcY8HLuxgO7FU%2FshrtPth-20191029_2019-10-29_08-31-01.png?alt=media\&token=f2eea536-9059-4525-b155-a7835f8e23bc)

{% file src="/files/-LsN73WZPwHlp2\_sKlQA" %}

![Shortest Path without optimizing for bends reduction](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LsN6-K-qXi07e9Cytyw%2F-LsN6i5ZNfubvkWjH0XX%2FshrtPth-20191029_2019-10-29_08-34-29.png?alt=media\&token=2683211c-48f6-4b48-9984-7962d25719c9)

```d
//Shortest Path
def ner(st,en,dr,cr:var[]..[])
{
	c1 = List.FilterByBoolMask(cr,st.DistanceTo(cr)==0)["in"];
	e1 = List.Flatten(List.SetDifference(List.Transpose([c1.StartPoint,c1.EndPoint])<1>,st),-1);
	c2 = List.SortByKey(c1, e1.DistanceTo(en))["sorted list"];
	e2 = List.SortByKey(e1, e1.DistanceTo(en))["sorted list"];
	d2 = c2.TangentAtParameter(c2.ParameterAtPoint(e2));

	b2 = Vector.ByTwoPoints(c2.StartPoint,c2.EndPoint).IsParallel(dr);
	c3 = List.IsEmpty(List.FilterByBoolMask(c2,b2)["in"]) ? c2[0] : List.FilterByBoolMask(c2,b2)["in"][0];
	e3 = List.IsEmpty(List.FilterByBoolMask(e2,b2)["in"]) ? e2[0] : List.FilterByBoolMask(e2,b2)["in"][0];
	d3 = c3.TangentAtParameter(c3.ParameterAtPoint(e3));

	return [[c2[0],e2[0],d2[0]],[c3,e3,d3]];
};

def shPh1 (st,en,crvs:var[]..[])
{
	dr = Vector.ByTwoPoints(st,en);
	ds = st.DistanceTo(en);
	shPth1 = [Imperative]
	{
		ph = [];
		ct = 0;
		while (ds > 0)
		{
			cr = ner(st,en,dr,crvs)[0];
			ph[ct] = cr[0];
			st = cr[1];
			dr = cr[2];
			crvs = List.SetDifference(crvs,ph);
			ds = st.DistanceTo(en);
			ct = ct + 1;
		}
		return ph;
	}
	return shPth1;
};

def shPh2 (en1,en2,en,crvs:var[]..[])
{
	cv1 = Math.Sum(shPh1 (en1,en,crvs).Length);
	cv2 = Math.Sum(shPh1 (en2,en,crvs).Length);
	return cv1 >= cv2 ? 1 : 0;
};

def shPh3 (st1,en1,cvs:var[]..[])
{
	return = [Imperative]
	{
		cv1 = ner(st1,en1,Vector.ByTwoPoints(st1,en1),cvs);
		ne1 = cv1[shPh2 (cv1[0][1],cv1[1][1],en1,cvs)];
		ph = [ne1[0]];
		st = ne1[1];
		dr = ne1[2];
		ds = st.DistanceTo(en1);
		ct = 1;

		while (ds > 0)
		{
			cs = List.SetDifference(cvs,ph);
			cr = ner(st,en1,dr,cs);
			ne = cr[shPh2 (cr[0][1],cr[1][1],en1,cs)];
			ph[ct] = ne[0];
			st = ne[1];
			dr = ne[2];
			ds = st.DistanceTo(en1);
			ct = ct + 1;
		}
		return ph;
	}
};

//Sample Grid
a = 0..100..10;
p1 = Point.ByCoordinates(a<1>,a<2>);
p2 = List.Transpose(p1);
p3 = List.DropItems(List.Sublists(p1<1>,0..1,1)<1>,-1);
p4 = List.DropItems(List.Sublists(p2<1>,0..1,1)<1>,-1);
l1 = Line.ByBestFitThroughPoints(List.Flatten([p3,p4],2));

r1 = Rectangle.ByCornerPoints(Point.ByCoordinates([0,0,100,100],[0,100,100,0]));
r2 = Rectangle.ByCornerPoints(Point.ByCoordinates([30,30,70,70],[10,70,70,10]));
s1 = r1.Patch().TrimWithEdgeLoops([r1,r2]);
l2 = List.RemoveIfNot(List.Flatten(l1.Intersect(s1),-1),"Line");
```

![Shortest path of specified gradient along topography ](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLSmNpWaJL8paFb7lp%2F-LhLSsdxXKDEE5z1T9xl%2FshortestPath.jpg?alt=media\&token=d7b0aa60-78a9-4127-a85e-f8e9c8e77ba7)


# Solar Analysis

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM4xg4g_mV0LJLjGoh%2F-LhM56sVnwRsQuFEA0u6%2FSolar.png?alt=media\&token=cf4e68e9-2af4-466b-958e-cb5d3f5f23cf)

```d
cp=Point.Origin();
rd=3;
a1=Line.ByStartPointDirectionLength(Point.ByCoordinates(rd,0,0),Vector.ZAxis(),rd);
a2=Arc.ByCenterPointStartPointEndPoint(cp,Point.ByCoordinates(0,0,rd),Point.ByCoordinates(rd,0,0));
asrf=Surface.ByRevolve(a2,cp,Vector.ZAxis(),0,360);

//Solar Study
solarstudy=SolarAnalysis.Analyze(Weather.ByLatitudeLongitude
(12.9716,77.5946),asrf,[],
TimeStudy.FromStartTimeToEndTime(DSCore.DateTime.
FromString("April 30, 2016 9:00 AM"),DSCore.DateTime.
FromString("April 29, 2017 6:00 PM"),false),0.125,0);
cumulative=List.Flatten(solarstudy["Cumulative"],1);
average=List.Flatten(solarstudy["Average"],1);
peak=List.Flatten(solarstudy["Peak"],1);
calculationpoints=List.Flatten(solarstudy["Calculation Points"],1);

cumPt=List.SortByKey(Flatten(calculationpoints),Flatten(cumulative))["sorted list"];
avgPt=List.SortByKey(Flatten(calculationpoints),Flatten(average))["sorted list"];
pekPt=List.SortByKey(Flatten(calculationpoints),Flatten(peak))["sorted list"];

//Colors
Color.ByARGB(255,[0,0,255],[0,255,0],[255,0,0]);
0..2;
0..1..#List.Count(cumPt);

//Angles
cumPhi=(Vector.XAxis()).AngleWithVector(((List.LastItem(cumPt)).Project(Plane.XZ(),Vector.YAxis())).AsVector());
cumThe=(Vector.XAxis()).AngleWithVector(((List.LastItem(cumPt)).Project(Plane.XY(),Vector.ByCoordinates(0,0,-1))).AsVector());

avgPhi=(Vector.XAxis()).AngleWithVector(((List.LastItem(avgPt)).Project(Plane.XZ(),Vector.YAxis())).AsVector());
avgThe=(Vector.XAxis()).AngleWithVector(((List.LastItem(avgPt)).Project(Plane.XY(),Vector.ByCoordinates(0,0,-1))).AsVector());

pekPhi=(Vector.XAxis()).AngleWithVector(((List.LastItem(pekPt)).Project(Plane.XZ(),Vector.YAxis())).AsVector());
pekThe=(Vector.XAxis()).AngleWithVector(((List.LastItem(pekPt)).Project(Plane.XY(),Vector.ByCoordinates(0,0,-1))).AsVector());
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM4xg4g_mV0LJLjGoh%2F-LhM5GeQn-dGGq6uM6iE%2FSolar-1.jpg?alt=media\&token=f4d2f69a-ad3b-421b-a867-5f6a882dc284)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM4xg4g_mV0LJLjGoh%2F-LhM5K7xCxt-YpdPluFI%2FSolar-02.jpg?alt=media\&token=6dce3d28-e848-4bd4-b312-f342dca6a5a5)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM4xg4g_mV0LJLjGoh%2F-LhM5MlYgQK_Kajs3bRJ%2FSolar-03.jpg?alt=media\&token=619c5d44-fb5e-4473-ae38-66a576e29fbf)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM4xg4g_mV0LJLjGoh%2F-LhM5PDrKcBZg9dHhygV%2FSolar-04.jpg?alt=media\&token=0f59f95d-4982-4cc0-a100-4cd7fc872811)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM4xg4g_mV0LJLjGoh%2F-LhM5S6uu50KGa1aCfHK%2FSolar-05.jpg?alt=media\&token=ce45c61f-3bd3-410d-b928-ee2d2fbfba0f)


# Topography Analysis

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLT2NofVK5e8OCbLm4%2F-LhLTE0BiobwjyKEcith%2FTopoColor.jpg?alt=media\&token=d60326fc-679d-48e0-8be3-492fb4d629b3)

{% file src="/files/-LhLTiv8qriT8DALOBIg" %}

```d
TopoMesh=TopoRev.Mesh;
TopoVer=TopoMesh.VertexPositions;
TopoInd=TopoMesh.FaceIndices;
MesVerA=List.GetItemAtIndex(TopoVer,TopoInd.A);
MesVerB=List.GetItemAtIndex(TopoVer,TopoInd.B);
MesVerC=List.GetItemAtIndex(TopoVer,TopoInd.C);
MesSur=Surface.ByPerimeterPoints(List.Transpose([MesVerA,MesVerB,MesVerC]));

//Color
Cols=[Color.ByARGB(255,255,0,0),Color.ByARGB(255,0,0,255),Color.ByARGB(255,0,255,0)];
ColInd=[0,0.95,1];

//Surface Normal Angle To Vertical
MesNor=MesSur.NormalAtPoint(MesSur.PointAtParameter(0.5,0.5));
NorAng=MesNor.Dot(Vector.ZAxis());
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLT2NofVK5e8OCbLm4%2F-LhLTnWY4neD18tRV2Ry%2FTopoColor-nodes1.jpg?alt=media\&token=85370184-5e33-43bb-bcbc-df60ea0da679)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLT2NofVK5e8OCbLm4%2F-LhLTpzpzEUr5lOG7x0l%2FTopoColor-nodes-2.jpg?alt=media\&token=43bf18d7-044f-4c12-82f2-8541b160490c)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLT2NofVK5e8OCbLm4%2F-LhLTsnKKj-98QevZzye%2FTopoColor-nodes-3.jpg?alt=media\&token=3f1e127e-148c-46bb-8b38-87af3837b765)

{% file src="/files/-LhLTyM9nwTa14xyQpEh" %}


# Adjacency

Space Adjacency

#### Adjacency - Linear

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM29kG2EoGJZY_gj-s%2F-LhM2BrgsvaD1YALAKD7%2Fadjacency-linear.gif?alt=media\&token=8bfe9141-36c3-4d68-a53c-14d8d6c2743d)

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

```d
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];
```

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

{% file src="/files/-LhLMnWqck9z6ksJAAwO" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLLyY3rj5qhkg38WZA%2F-LhLMcPTdHkSBMB56ZLi%2Fadjacency-L.png?alt=media\&token=414c5b86-1df2-4633-a7c4-07128767422c)

#### Adjacency - Pairs

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM29kG2EoGJZY_gj-s%2F-LhM2FDzkujAITV1SgR_%2Fadjacency-pairs.gif?alt=media\&token=543ebce4-2383-4ccc-a4d9-7abcbe3f7b0e)

```d
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;
}
};
```

```d
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];
```

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

{% file src="/files/-LhLNUey0ZIUFzgxhNrS" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLNgcQl94F9ftAHkXV%2F-LhLNkvVBHLC5zHsgnJl%2Fadjacency-M.png?alt=media\&token=f4ee76fb-f509-4757-a900-68ca0b666b62)


# Animate Sphere

Periodic Run

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh94v3lKEJa_l34brzH%2F-Lh984WbOmUR650sS9iE%2FamimateSphere.gif?alt=media\&token=459e8b71-c313-4667-bba8-cda0f2919be3)

```d
//Seconds to Parameter
msc = DSCore.DateTime.Components(dtm)["second"];
prm = msc>30?(60-msc)/30:msc/30;

//Curve
crv = NurbsCurve.ByPoints(Point.ByCoordinates
([0,10,-10,5],[0,10,5,-5],[0,10,5,0]));

//Sphere
sph = Sphere.ByCenterPointRadius(crv.PointAtParameter(prm),2);
```


# Cellular Automation

Conway's Game of Life

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MFVu6avu56sROmWDaks%2F-MFVuEFETorV52uxEjYM%2FgameOfLife1.gif?alt=media\&token=79305f85-0c31-4a34-9b0b-806db69261f4)

**Conway's Game of Life**, also known as the **Game of Life** or simply **Life**, is a [cellular automaton](https://www.conwaylife.com/wiki/Cellular_automaton) devised by the British mathematician [John Horton Conway](https://www.conwaylife.com/wiki/John_Horton_Conway) in 1970. It is the best-known example of a cellular automaton.

The "game" is actually a zero-player game, meaning that its evolution is determined by its initial state, needing no input from human players. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square [cells](https://www.conwaylife.com/wiki/Cell), each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

1. Any live cell with fewer than two live neighbours dies (referred to as **underpopulation** or **exposure**[\[1\]](https://www.conwaylife.com/wiki/Conway's_Game_of_Life#cite_note-1)).
2. Any live cell with more than three live neighbours dies (referred to as **overpopulation** or **overcrowding**).
3. Any live cell with two or three live neighbours lives, unchanged, to the next generation.
4. Any dead cell with exactly three live neighbours will come to life.

The initial pattern constitutes the 'seed' of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed — births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a tick. (In other words, each generation is a pure function of the one before.) The rules continue to be applied repeatedly to create further generations.

![Conway's Game of Life](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MFV3tItbtyhhtplLFjW%2F-MFV52dPTRmLDmN-5_jE%2FgameOfLife.gif?alt=media\&token=011166d5-72ed-43ca-bc84-8e5eb99d4241)

```d
// Conway's Game of Life
def goL(l1:bool[]..[])
{
	mdRw = 0..List.FirstItem(List.Count(l1<1>))-1;
	bln1 = List.GetItemAtIndex(List.ShiftIndices(l1,[1,0,-1])<1><2>,List.ShiftIndices(mdRw,[1,0,-1]));
	bln2 = List.Flatten(List.Transpose(List.Transpose(List.Transpose(bln1<1><2>))<1>)<1><2>,-1);
	tru1 = List.CountTrue(bln2<1><2>);
	bln3 = List.GetItemAtIndex(bln2<1><2>,4) ? (tru1<3 || tru1>4 ? false : true) : (tru1==3 ? true :false);
	return bln3;
};// Iterations
```

```d
// Iterations
def GoL(bl:bool[]..[],n:int)
{
	return = [Imperative]
	{
		b = bl;
		for (c in (1..n))
		{
			a = goL(b);
			b = a;
		}
		return b;
	}
};
```

```d
// Initial Configuration
x = 20;
y = 26;
allPnt = Point.ByCoordinates((0..x)<1>,(0..y)<2>);

//Glider
flsPnt = List.Flatten([allPnt[1][y-3],allPnt[2][y-4],allPnt[3][y-(2..4)]],-1);

//Booleans
blnLst = List.Contains(flsPnt,allPnt<1><2>);
pnt1 = List.FilterByBoolMask(allPnt,GoL(blnLst,n));
gol1 = [GeometryColor.ByGeometryColor(List.Clean(Cuboid.ByLengths(pnt1["in"],1,1,1),false),Color.ByARGB(255,255,153,51)),
GeometryColor.ByGeometryColor(List.Clean(Sphere.ByCenterPointRadius(pnt1["out"],0.5),false),Color.ByARGB(255,76,153,0))];

```

{% file src="/files/-MFVnMs1UbCQFimq9RMl" %}
Dynamo Version 2.9
{% endfile %}


# Cloth

Approximation of cloth draped over a surface

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MC2mHzV-_3nC2oRvupr%2F-MC2mUEIqcUdjmbqunTY%2Fcloth.gif?alt=media\&token=3090c320-63dc-484f-be5e-5357dfd7d49a)

```d
obmx = obj1.BoundingBox.MaxPoint;
obmn = obj1.BoundingBox.MinPoint;
obcn = Point.ByCoordinates((obmx.X + obmn.X)/2 , (obmx.Y + obmn.Y)/2 , obmx.Z);

clt2 = clt1.Translate(Vector.ZAxis(), obmx.Z).PerimeterCurves();
clt3 = clt2.PointAtParameter(0..1..#(clt2.Length/2));

cll1 = Line.ByStartPointEndPoint(clt3<1>,obcn);
cll2 = PolyCurve.ByJoinedCurves(obj1.ProjectInputOnto(cll1,Vector.ByCoordinates(0,0,-1)));
cll3 = Line.ByStartPointDirectionLength(cll2.StartPoint,Vector.ZAxis(),cll2.Length-cll1.Length);

cld1 = NurbsCurve.ByPoints(cll3.EndPoint).Length/(clt2.Length/2);
cld2 = Math.Sqrt(Math.Pow(clt2.Length/(clt2.Length/2),2)-Math.Pow(cld1,2));

cld3 = List.Shuffle(List.Flatten(List.Transpose(List.Transpose([List.Cycle(0,Math.Floor(List.Count(cll3.EndPoint<1>)/2)),List.Cycle(cld2<1>,Math.Ceiling(List.Count(cll3.EndPoint<1>)/2)<1>)])<1>)<1>,-1)<1>);
dis1 = Vector.ByTwoPoints(Point.ByCoordinates(obcn.X,obcn.Y,List.MinimumItem(List.Flatten(cll3.EndPoint,-1).Z)),cll3.EndPoint);

clc1 = PolyCurve.ByJoinedCurves(obj1.PerimeterCurves());

clc2 = NurbsCurve.ByPoints(List.Clean(List.Flatten(cll3.EndPoint.Translate(dis1,cld3),-1),false),true);

srf1 = PolySurface.ByJoinedSurfaces(List.Flatten([obj1,Surface.ByLoft([clc1,clc2])],-1));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MC1izlOAdUUW5jauqY9%2F-MC1jmMaU1higHlVJtls%2Fcloth1_2020-07-12_04-46-54.png?alt=media\&token=1282ffcd-edac-4d76-afbd-36e12f4baede)

{% file src="/files/-MC1juXCro2\_qZBqxA2X" %}
Dynamo ver 2.8
{% endfile %}


# Hypotrochoid

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LdGHERPs5OcNUhq_vvk%2F-LdGLmLrfOBWqt8Q2mIo%2FHypotrochoid-3.png?alt=media\&token=a4bef83e-8537-4d5b-8a0b-76d21ba211b8)

```d
R = 10;
r = 4;
d = 10;
a = 750;

x = (R-r)*Math.Cos(0..a)+d*Math.Cos(((R-r)/r)*(0..a));
y = (R-r)*Math.Sin(0..a)-d*Math.Sin(((R-r)/r)*(0..a));

p = Point.ByCoordinates(x,y);
s = NurbsCurve.ByPoints(p);
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LfT-gaWC3M6518JXr5a%2F-LfT-lL2xIwf8CkLJfAx%2FHypotrochoid.gif?alt=media\&token=456a19ff-bbf8-4e16-8180-0ae188bfc622)

```d
//Hypotrochoid
R = 5;
r = 3;
d = 5;
a = 0..n..1;
x = (R-r)*Math.Cos(a)+d*Math.Cos(((R-r)/r)*a);
y = (R-r)*Math.Sin(a)-d*Math.Sin(((R-r)/r)*a);
p1 = Point.ByCoordinates(x,y);

//Graphics for animation
p2 = (Point.Origin().Translate(Vector.XAxis(),R-r))
.Rotate(Point.Origin(),Vector.ZAxis(),a);
l1 = Line.ByStartPointEndPoint(p1,p2);
c1 = Circle.ByCenterPointRadius(Point.Origin(),R);
c2 = Circle.ByCenterPointRadius(p2,r);
[p1,c1,List.LastItem(l1),List.LastItem(c2)];
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-Lh99J-YcJHuKlvtKxFp%2F-Lh99MSgVxg92X_9mruQ%2FHypotrochoid-2a.png?alt=media\&token=b02ee6f7-79d6-48c4-a293-dcf3ae2bef85)


# Manakin

Human Stick Figure

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhM1u-3M-2EWIumGbll%2F-LhM238VvM3FXLnvXFXj%2Fmanikin.gif?alt=media\&token=ea612bb5-6094-4386-85d1-6bdcc9d92c2e)

```d
basePoint=Point.Origin();
h=stature;
s=Point.ByCartesianCoordinates(CoordinateSystem.ByOrigin(basePoint),-0.0955*h,0,0);
dirX=Vector.XAxis();
dirY=Vector.YAxis();
dirZ=Vector.ZAxis();
sll1=Line.ByStartPointDirectionLength(s,dirZ,0.039*h);
sll2=Line.ByStartPointDirectionLength(sll1.EndPoint,dirZ,0.246*h);
dlkn=seated?dirY.Reverse():dirZ;
sll3=Line.ByStartPointDirectionLength(sll2.EndPoint,dlkn,0.245*h);
shp1=Line.ByStartPointDirectionLength(sll3.EndPoint,dirX,0.191*h);
drkn=seated?dirY:dirZ.Reverse();
slr3=Line.ByStartPointDirectionLength(shp1.EndPoint,drkn,0.245*h);
slr2=Line.ByStartPointDirectionLength(slr3.EndPoint,dirZ.Reverse(),0.246*h);
slr1=Line.ByStartPointDirectionLength(slr2.EndPoint,dirZ.Reverse(),0.039*h);
ssp1=Line.ByStartPointDirectionLength(shp1.PointAtParameter(0.5),dirZ,0.288*h);
slh1=Line.ByStartPointDirectionLength(ssp1.EndPoint,dirX.Reverse(),0.1295*h);
slh2=Line.ByStartPointDirectionLength(slh1.EndPoint,dirZ.Reverse(),0.186*h);
slh3=Line.ByStartPointDirectionLength(slh2.EndPoint,elbowBent?dirY:dirZ.Reverse(),0.146*h);
slh4=Line.ByStartPointDirectionLength(slh3.EndPoint,elbowBent?dirY:dirZ.Reverse(),0.108*h);
srh1=Line.ByStartPointDirectionLength(ssp1.EndPoint,dirX,0.1295*h);
srh2=Line.ByStartPointDirectionLength(srh1.EndPoint,dirZ.Reverse(),0.186*h);
srh3=Line.ByStartPointDirectionLength(srh2.EndPoint,elbowBent?dirY:dirZ.Reverse(),0.146*h);
srh4=Line.ByStartPointDirectionLength(srh3.EndPoint,elbowBent?dirY:dirZ.Reverse(),0.108*h);
chn1=Line.ByStartPointDirectionLength(ssp1.EndPoint,dirZ,0.051*h);
hed1=Circle.ByCenterPointRadiusNormal((chn1.EndPoint).Translate(dirZ,h*0.0655),h*0.0655,dirY);
sktn=[sll1,sll2,sll3,shp1,slr3,slr2,slr1,ssp1,slh1,slh2,slh3,slh4,srh1,srh2,srh3,srh4,chn1,hed1];
psnrt=sktn.Rotate(basePoint,dirZ,rotate);
//Reach boundary extents
rlxl=1.1;
rlxh=1.2;
rchll=Surface.ByPatch(Circle.ByCenterPointRadiusNormal(shp1.StartPoint,0.530*h*rlxl,dirY));
rchrl=Surface.ByPatch(Circle.ByCenterPointRadiusNormal(shp1.EndPoint,0.530*h*rlxl,dirY));
rchlh=Surface.ByPatch(Circle.ByCenterPointRadiusNormal(slh1.StartPoint,0.440*h*rlxh,dirY));
rchrh=Surface.ByPatch(Circle.ByCenterPointRadiusNormal(srh1.StartPoint,0.440*h*rlxh,dirY));
rchsol1=Solid.ByUnion([rchll.Thicken(h*0.001,true),rchrl.Thicken(h*0.001,true),rchlh.Thicken(h*0.001,true),rchrh.Thicken(h*0.001,true)]);
rchsol=rchsol1.Trim(Plane.ByOriginNormal(basePoint,Vector.ZAxis()),basePoint.Add(Vector.ByCoordinates(0,0,-1)));
rchsur=rchsol.Intersect(Plane.ByOriginNormal(rchsol1.Centroid(),Vector.YAxis()));
rchper=Flatten(rchsur.PerimeterCurves());
rchpnt1=Flatten(rchper<1><2>.PointAtParameter(0.1..0.9..#6)<1>);
rchpnt=rchpnt1.Rotate(basePoint,dirZ,rotate);
rchcur=NurbsCurve.ByControlPoints(rchpnt,3,true);
```

{% file src="/files/-LhLQYLesK51nyAmiP4v" %}

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-LhLQ5O3Se5VMtJFVRMn%2F-LhLQOYi48AWk5InkKKv%2FDynamanikin.png?alt=media\&token=4b244d09-d34e-4c22-88b8-d29624dc5002)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2F60wfwO882xEEkpHhsuvn%2Fmanekin_2022-06-23_09-52-38.png?alt=media\&token=91d17c81-6a61-4529-b462-8f94ea872366)

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FNLXul9KooDXxbDtl02cu%2Fmanekin_2022-06-24_10-13-30.png?alt=media\&token=b663fec2-bd48-4353-9c82-969ce4d767cf)

```d
skull = 300;
frhed = 200;
shldr = 500;
uparm = 300;
lwarm = 300;
torso = 650;
waist = 350;
femur = 500;
tibia = 500;
fooot = 150;


headAn = -5;
trsoAn = -30;
ftTbAn = 30;
tbFmAn = 150;

vct01 = Vector.ZAxis().Rotate(Vector.XAxis(),[headAn,trsoAn,tbFmAn,ftTbAn]);
toe01 = Point.Origin();
ank01 = toe01.Translate(Vector.YAxis(),fooot);
kne01 = ank01.Translate(vct01[3].Reverse(),tibia);
hip01 = kne01.Translate(Vector.YAxis(),femur);
tor01 = hip01.Translate(vct01[1],torso);
hed01 = tor01.Translate(vct01[0],skull);

// head
hed02 = hed01.Translate(Vector.XAxis(),[frhed/2,-frhed/2]);
hed03 = PolyCurve.ByPoints(List.Flatten([hed02,tor01],-1),true).Explode();

// torso
tor02 = tor01.Translate(Vector.XAxis(),[shldr/2,-shldr/2]);
hip02 = hip01.Translate(Vector.XAxis(),[waist/2,-waist/2]);
tor03 = PolyCurve.ByPoints(List.Flatten([tor02,List.Reverse(hip02)],-1),true).Explode();

// arm
arm01 = tor02.Translate(Vector.ByCoordinates(0,-1,-1),uparm).Translate(Vector.ByCoordinates([1,-1],0,0),100);
arm02 = arm01.Translate(Vector.YAxis(),-lwarm);
arm03 = PolyCurve.ByPoints(List.Transpose([tor02,arm01,arm02]),false);

// legs
leg01 = PolyCurve.ByPoints([hip01,kne01,ank01,toe01],false).Translate(Vector.XAxis(),[waist/2,-waist/2]);

List.Flatten([hed03,tor03,arm03,leg01].Explode(),-1);
```


# Rolling Spiral

Sin and Cos

![Rolling Spiral](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSWDF0IGCw2CUfcxR7m%2F-MSWDUL7KyWkcOT0IQ8q%2FsinCosSpiral.gif?alt=media\&token=48a0ded0-465d-4bde-bc11-20b0e2930a2a)

```d
a = Dictionary.ValueAtKey(DateTime.Components(d), "second")*12;

x1 = (0..(Math.PiTimes2)..#500);
y1 = Math.Sin(a..(a+360)*3..#500);
z1 = Math.Cos(a..(a+360)*3..#500);
n1 = NurbsCurve.ByPoints(Point.ByCoordinates(x1,y1+4));
n2 = NurbsCurve.ByPoints(Point.ByCoordinates(x1,0,z1+4));
n3 = NurbsCurve.ByPoints(Point.ByCoordinates(x1,y1+4,z1+4));
l1 = Line.ByStartPointEndPoint(n1.StartPoint,n3.StartPoint);
l2 = Line.ByStartPointEndPoint(n2.StartPoint,n3.StartPoint);
c1 = GeometryColor.ByGeometryColor([n1,l1],Color.ByARGB(255,0,0,255));
c2 = GeometryColor.ByGeometryColor([n2,l2],Color.ByARGB(255,255,0,0));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSWEdFo5OQnGGymeKZm%2F-MSWEtxPhm6x5eC13t17%2Fspiral_2021-01-31_01-39-20.png?alt=media\&token=06d54b94-fa2a-4c0d-93a1-a44270f93552)

{% file src="/files/-MSWDt-Q8pf\_ofqE8Kzh" %}


# Tan Curve

Ascending Tan Curve

![Tan Curve Graph](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSWAXoDfiYgt8FvT6TK%2F-MSWD4zfpeIzBRPtTBf9%2FtanCurve.gif?alt=media\&token=8194b634-a967-4ece-9db2-b27022129e31)

```d
a = Dictionary.ValueAtKey(DateTime.Components(d), "second")*(1000/60);

x1 = 0..Math.PiTimes2..#1000;
y1 = Math.Tan(0..360..#1000);
p1 = Point.ByCoordinates(List.TakeItems(x1,a),List.TakeItems(y1,a));

//Visualization
p2 = Point.ByCoordinates(-1,List.LastItem(p1).Y);
a1 = Circle.ByCenterPointRadius(Point.ByCoordinates(-2),1);
l1 = Line.ByStartPointEndPoint(Point.ByCoordinates(-2),p2);
l2 = Line.ByStartPointEndPoint(List.LastItem(p1),p2);
l3 = Line.ByStartPointEndPoint(p2,Point.ByCoordinates(p2.X));
l4 = Line.ByStartPointEndPoint(List.LastItem(p1),Point.ByCoordinates(List.LastItem(p1).X));
c1 = GeometryColor.ByGeometryColor(p1,Color.ByARGB(255,255,0,0));
c2 = GeometryColor.ByGeometryColor([l1,l2],Color.ByARGB(255,0,0,255));
c3 = GeometryColor.ByGeometryColor([l3,l4],Color.ByARGB(255,255,165,0));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSWERojupGR-YH-fxpo%2F-MSWEakH6hLTVJAtyLn9%2FtanCurve_2021-02-02_11-06-35.png?alt=media\&token=3f6fe6f7-89c6-4486-a549-975e2fd7545f)

{% file src="/files/-MSWCzsB\_DlstTMJRLNr" %}
Dynamo Version 2.11
{% endfile %}

![Rising Tan](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSW8-65cPkSSNOLnfXd%2F-MSW8NAPP8IWqb96uKrh%2FrisingTan.gif?alt=media\&token=97c7659e-a6d2-475f-b1b5-03b7f83e058a)

```d
a = Dictionary.ValueAtKey(DateTime.Components(d), "second")-1;

x = Math.Tan(280..440..#60);
y = (0..Math.PiTimes2..#60)/5;
yy1 = List.Flatten(List.Transpose([List.OfRepeatedItem(0,60-(1..60)),List.TakeItems(y,(1..60))])<1>,-1);
pt1 = Point.ByCoordinates(x,yy1<1>);
nc1 = NurbsCurve.ByPoints(pt1,1);
nc2 = List.LastItem(nc1).Translate(Vector.YAxis(),List.LastItem(yy1));
nc3 = List.GetItemAtIndex(nc2,a).Translate(Vector.YAxis(),(0..#4..1.3));
nc4 = List.GetItemAtIndex([nc1,nc2]<1>,a);

//Visualization
ln1 = Line.ByStartPointEndPoint(nc1[0].StartPoint,nc1[0].EndPoint);
ln2 = Line.ByStartPointDirectionLength(Point.ByCoordinates(0,-2.5),Vector.YAxis(),9);
pt2 = List.GetItemAtIndex(List.Reverse(pt1<1>),a);
pt3 = List.GetItemAtIndex(pt2,List.IndexOf(Math.Round(pt2.Y,3),0.0));
ln3 = Line.ByStartPointEndPoint(Point.ByCoordinates(0,-1),Point.ByCoordinates(pt3.X)).ExtendStart(1);
ci1 = Circle.ByCenterPointRadius(Point.ByCoordinates(0,-1),1);
ci2 = Circle.ByCenterPointRadius([ln3.StartPoint,ln3.EndPoint],0.1).Patch();
ln4 = ln3.ExtendStart(10);

//Color
cl1 = GeometryColor.ByGeometryColor(ci1,Color.ByARGB(255,0,0,255));
cl2 = GeometryColor.ByGeometryColor(ci2,Color.ByARGB(255,255,0,0));
cl3 = GeometryColor.ByGeometryColor(ln4,Color.ByARGB(255,0,255,0));
cl4 = GeometryColor.ByGeometryColor([ln1,ln2],Color.ByARGB(255,0,255,255));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSW8-65cPkSSNOLnfXd%2F-MSW8YUKysWAyzeCI05T%2FrisingTan_2021-02-02_10-23-47.png?alt=media\&token=52f90ea7-54fb-4290-927d-1b2f9f4d0196)

{% file src="/files/-MSW9APekPqs\_z-ou1Lt" %}
Dynamo Version 2.11
{% endfile %}


# Trammel of Archemedes

![Trammel of Archemedes](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSWDuxo3Y-Glc8EWbw7%2F-MSWE6OPpjq519aLvzMC%2FtrammelOfArchemedes.gif?alt=media\&token=5b42d443-d403-4edf-9d48-cf270d762af1)

```d
a = Math.Ceiling(Dictionary.ValueAtKey(DateTime.Components(d), "second")*0.58);

ps1 = 3;
xx1 = -5..5..#30;
yy1 = Math.Sqrt(ps1*ps1-Math.Pow(xx1,2));
sg1 = List.FilterByBoolMask(Math.Sign(xx1),yy1>0)["in"];
xx2 = Math.Round(List.FilterByBoolMask(xx1,yy1>0)["in"],6);
yy2 = Math.Round(List.FilterByBoolMask(yy1,yy1>0)["in"],6)*sg1;

pv1 = Point.ByCoordinates(xx2);
pv2 = Point.ByCoordinates(0,yy2);
ln1 = List.Flatten(Line.ByStartPointEndPoint(pv1,[pv2,List.Reverse(pv2)]<1>),-1);
an1 = ln1.ExtendEnd(3).EndPoint.AsVector().AngleAboutAxis(Vector.XAxis(),Vector.ZAxis());
ln2 = List.SortByKey(ln1,an1)["sortedList"];
ln3 = List.GetItemAtIndex(ln2,a);

//Solids
cl1 = Circle.ByCenterPointRadius(ln3.StartPoint,0.07).ExtrudeAsSolid(Vector.ZAxis(),0.125);
cl2 = Circle.ByCenterPointRadius(ln3.EndPoint,0.07).ExtrudeAsSolid(Vector.ZAxis(),0.125);
cl3 = Circle.ByCenterPointRadius(ln3.ExtendEnd(4.15).EndPoint,0.1).ExtrudeAsSolid(Vector.ZAxis(),0.15);
ln4 = PolyCurve.ByThickeningCurveNormal(ln3.ExtendEnd(4.5).ExtendStart(0.15),0.5,Vector.ZAxis()).ExtrudeAsSolid(Vector.ZAxis(),0.05);
rt1 = Rectangle.ByWidthLength(0.75,0.5).Translate(Vector.XAxis(),ln3.StartPoint.X).ExtrudeAsSolid(Vector.ZAxis(),-0.2);
rt2 = Rectangle.ByWidthLength(0.5,0.75).Translate(Vector.YAxis(),ln3.EndPoint.Y).ExtrudeAsSolid(Vector.ZAxis(),-0.2);
rt3 = Rectangle.ByWidthLength(3,3).Translate([1.75,1.75,-1.75,-1.75],[1.75,-1.75,-1.75,1.75],-0.1).ExtrudeAsSolid(Vector.ZAxis(),-0.1);
rt4 = Solid.ByUnion(List.Flatten([rt3,Rectangle.ByWidthLength(6.5,6.5).Translate(0,0,-0.2).ExtrudeAsSolid(Vector.ZAxis(),-0.3)],-1));

//Color
cr1 = GeometryColor.ByGeometryColor(ln4,Color.ByARGB(255,204,102,0));
cr2 = GeometryColor.ByGeometryColor([rt1,rt2],Color.ByARGB(255,255,255,0));
cr3 = GeometryColor.ByGeometryColor(rt4,Color.ByARGB(255,255,255,200));
cr4 = GeometryColor.ByGeometryColor([cl1,cl2,cl3],Color.ByARGB(255,0,255,200));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MSWDuxo3Y-Glc8EWbw7%2F-MSWEPUuOg051vVmACLt%2FarchemedesTrammel_2021-02-01_02-54-59.png?alt=media\&token=4730e85a-5389-4c76-8a77-d102ade27b43)

{% file src="/files/-MSWEMYHdSqQFqYQEThF" %}


# Image to Integer

Basic Machine Learning in F# and Dynamo

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FjPIf9IUImUNpvwPfqvaM%2FintImg-20211018-1.gif?alt=media\&token=4fcc06c4-1ce6-4773-ac4e-674aa9a9cb85)

{% embed url="<https://youtu.be/9sfFBX1b-pc>" %}
Inspiration for the node and source of code
{% endembed %}

```fsharp
namespace integerImage
open System.IO
module integerML =
    type Example = {
        Label : int
        Pixels : int []
    }
    
    let readExamples path = 
        path
        |> File.ReadAllLines
        |> Array.map (fun line -> line.Split ',')
        |> Array.map (fun line -> line |> Array.map int)
        |> Array.map (fun line -> {Label = line.[0]; Pixels = line.[1..]} )

    let distance (img1 : int[]) (img2 : int[]) =
        Array.map2 (fun pix1 pix2 -> abs(pix1 - pix2)) img1 img2
        |> Array.sum
    
    let classify (img : int[]) = 
        let bestMatch =
                readExamples (__SOURCE_DIRECTORY__ + "/train.csv")
                |> Array.minBy (fun x -> distance x.Pixels img)
        bestMat
```

```csharp
// Some codepublic class IntImg
{
    private IntImg() { }
    public static int intFrmImg(int[] tst)
    {
        return integerImage.integerML.classify(tst);
    }
}
```

{% embed url="<https://www.kaggle.com/rakuraku678/mnist-60000-hand-written-number-images>" %}
Training Set Source
{% endembed %}

{% file src="/files/7tp3ImOvgr3y9w0LVuEl" %}


# A Conceptual Approach to Integrating Computational Methods in Early Stage Design

Wandering some trails, lost in thought, contemplating the possible application of computational approaches to early stage design, I find myself in a jungle. With sunlight filtering through and craving a glimpse of the open sky beyond the foliage, the echo of waves draws me toward rugged cliffs. As I ascend, the foliage thins, the leaves give way to open space, and there it is - the vantage point. I stand on the precipice, toes gripping the edge and …..

…. I find my view obstructed&#x20;

…. by an imposing built form.

<figure><img src="https://lh7-us.googleusercontent.com/1QsUp9OqFUYPDY9vX0RtMyXp8EkQCkfvaLh-9kfJoFUT-U9o_LFuULknkf7P00Nyu3Q4qMiREpSvKOBafi7cPR6M4E5T9beXx4T3zMOhvWUurPcuUqo-W9gV3BjleIoBYaWBzae44mc2_W0el_yVveg" alt=""><figcaption></figcaption></figure>

Once my anguish over the insensitivity and incompetence that has resulted in this predicament subsides, I settle down and ponder as to what better choices the designer could have made for both the structure and the view co-exist.

I posit the designer could have ensured that the extents of the built form were curtailed to ensure unobstructed lines of sight to the coast beyond. Essentially a geometric analysis which could be represented and analyzed graphically, I begin to outline a possible computational approach.

1. Creating a Basic Scene: This involves digitally recreating the natural environment where the building will be situated. Peaks, coastlines, vegetation, and other landscape features are modeled to provide a realistic context for the design.
2. Identifying Suitable Locations: Computer-generated geometry is used to analyze the terrain and identify potential building sites that won't obstruct important views or disrupt the natural flow of the landscape.
3. Experimenting with Building Shapes: Architects can then experiment with various building shapes and forms, adjusting them to complement the surrounding environment. This could involve altering the building's footprint, height, orientation, and other parameters to achieve the desired integration with the landscape.
4. Optimizing Fit: Through iterative adjustments and experimentation, the design team can refine the building's placement and form to achieve the best possible fit within the natural surroundings. This iterative process allows for a back-and-forth exploration, ensuring that the final design harmonizes with the landscape while meeting functional and aesthetic requirements.

#### Objective

Generate a conceptual mass that would take into consideration specific criteria (peak and coast) and define the extents of the intended structure such that they satisfy a specific objective (unobstructed view).

Scene

Let us begin by preparing a conceptual scene that consists of a peak (a cone), a jagged coast-line (a poly-curve) and an initial building mass (a solid) that we will alter.

<figure><img src="https://lh7-us.googleusercontent.com/A8tzeWsqzbhNlvj62s42CVFswnibKO-QoXk4VyoS2YvhabOEkD-o8-oEGHVCAQS_QzpmfaYrX7Do7iQ4ZhvkjERxDeCGt42pCAovFJVI86uK094S4NQE_IQ2d7W5qoWMH8RIScp9Lyww8MR-0Rk4W_A" alt=""><figcaption></figcaption></figure>

<img src="https://lh7-us.googleusercontent.com/Zq6oG8L5ud1Kx1Xasgrq9O1oSgNUN-aWRu-mKTffQZCu7sr9FMUkV26DfkYyTYkY-_N7I3iWBKDMARfHRZzQBzT2gz-kZFfWPyJwsu6PIQrWDtpGFn6ZwGa-cV5O3KXP-rDHmKR2XRx6PDpCMLUaIjk" alt="" data-size="line">

```d
// Peak
height = 30;
coneStart = Point.ByCoordinates
(0,0,0);
coneEnd = Point.ByCoordinates
	(0,0,height);
peak = GeometryColor.ByGeometryColor
	(Cone.ByPointsRadius
	(coneStart, coneEnd, 25),
	Color.ByARGB(255,55,60,55));


// Coastline
coast = PolyCurve.ByPoints
	(Point.ByCoordinates
		([50,70,90,60,50,30,0,-50],
		[-50,0,25,50,80,60,70,50]));

// Base
base = PolyCurve.ByPoints
	(Point.ByCoordinates
		([50,70,90,60,50,30,0,-50,-50],
		[-50,0,25,50,80,60,70,50,-50]),
		true)
	.ExtrudeAsSolid(0.35);
baseClrd = GeometryColor.ByGeometryColor
	(base,Color.ByARGB(255,200,200,135));

// Water
water = GeometryColor.ByGeometryColor(
	Surface.ByLoft(
		[coast,coast.Offset(300)]),
		Color.ByARGB(50,75,205,235));

// Builing Mass
site = Rectangle.ByCornerPoints
	(Point.ByCoordinates
		([20,20,50,50],
		[50,30,30,50]));
mass = site.ExtrudeAsSolid(20);

// Color Solid
GeometryColor.ByGeometryColor(mass,
Color.ByARGB(255,225,185,145));
GeometryColor.ByGeometryColor(coast.Extrude(0.5).Thicken(0.5),
Color.ByARGB(255,0,0,255));

// Sight Lines
eye = coneEnd;
coastVertices = coast.Points;
sightLines = Line.ByStartPointEndPoint
	(eye, coastVertices);
```

#### Vantage

Considering the point at the top of the cone to be the eye level, plot lines from eye level the coast line vertices and loft these lines to create a surface.&#x20;

<br>

&#x20;![](https://lh7-us.googleusercontent.com/pRH9nNPVEZXlkQtolaEa7svtHa5qsPAhYPesOzK1bW8b66Bn5aP_F5ymOhTxvte2FjXvzdlyixhcyZe2bPQl7Mj_8eTYmEhoY-m6MYv8rwbVGOE_BkM0SBvjJMKnoNI0vbdUoAC8bYzGjRLIEM7-XkI)![](https://lh7-us.googleusercontent.com/TSPwhp9lkvB_HNs-8UtqmVd2mtB_sGn4BmC6vpm6fFv4W-IqFlaZfXACeQWsjrOaVar6Bxl3ZAsCDvr2ah2Lzf-TqniVWL7x2QkXNqUYqi_pEcRyG7fDbhXoZ2wxbOrFfns0nATuTVUu0Bbpp_pFoIA)

Extents

The lofted surface intersects the building mass and splits it in two. The portion above the lofted surface would obstruct views of the coast from the peak and will need to be trimmed. The resulting mass would ensure an unobstructed view from the peak despite its presence.

<figure><img src="https://lh7-us.googleusercontent.com/-ZKgKxvnizRLp83GjeIgicoiQriGYgpOXlT5DhfwiA9XgwA_wbsBtfVhXBlyl5XWrp82iqYFb2N-3_m-3YM4ZZp8N8ZhStZNUHnF49m-U0RdziFGPXlfg1Hhld7sh9d_FNEV0LbUFZP58lSBaY6fvoE" alt=""><figcaption></figcaption></figure>

<img src="https://lh7-us.googleusercontent.com/g5R86Z7mbwG86u9f9JffySYQC43UOkI4407ekZaIRYRgJNHqMmEy4Rzr-g4OewcPwAlZBS1laf82vuHw19fBbxW9IHFBKvy7q4JMbu4I82smHNwpq4LL6QbGjNJMZjoojbdSFYzfwrZMs_V-ht7E4-c" alt="" data-size="line">

```d
// Cutting Tool
cuttingTool = Surface.ByRuledLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool, Color.ByARGB(200,190,190,190));

// Trim Solid
trimmedSolid = Solid.Trim
	(mass,
	cuttingTool,
	Point.ByCoordinates(20,50,20));

// Color Solid
GeometryColor.ByGeometryColor(trimmedSolid,
Color.ByARGB(255,225,185,145));
```

#### Variation

The trimmed form is faceted as the cutting surface is created with a Ruled Loft

![](https://lh7-us.googleusercontent.com/07w8gW5KVRhc4GKFmrXRny5EBLmQLUpyRCjvMo7bKlZkRgEIoEREk4Mjvlk1cfPYsqqZ68G2x2WzSQiuwyNlNc2siLFkANGkcXKS95I1c3S-lQFpOcZ0uDlrueFUcB7E-5vm8PkfKioq03SXaAwWvmA)![](https://lh7-us.googleusercontent.com/VvrCX77_6L7AZFVoYVBEoxuhGBNI-3c8uPS2rW4beN2kYO_rctZV124pPjHBx5Jg4tzd-KxiY1kKP14jVSntc73abx02XHo_Lavt9Dzr5rA-t4VvGE3tsN1SZDzQDYv6_R0L8tVyZYlSVcD1BbjF9GY)

However if the cutting surface was created using a Loft, it would be smooth

![](https://lh7-us.googleusercontent.com/F3LJut2FxUuW9pj4qadSPbRlq1Ocb3HKXT59DSiACNZqUPR5oiwTlWZwcGHdJzzfjpYVuasVpRXChfb2nzTmUw4ASJwtky70Mm105C5VrePS3aLM4mXDbZ2-Bz157RZ00AaG_l2H3m1TM_L0BLC8H9U)![](https://lh7-us.googleusercontent.com/8ZzlkOiTpLdPK8RHexvdSQ7nFbtELx2SPpXoWIT8tRnsqRXBMgzYQza6H9OCtdvtpC0Kco47xcVzIGRbg2LYy-5MnyKX1HSSjr70hF-hvubTnc2QIcPLCAEoHL-F-w7NCAcTJ8lUbj--vojHUd0YJnE)

#### Alteration

While retaining the same workflow and code, while only replacing Surface.ByRuledLoft with Surface.ByLoft, an alternate geometry is obtained

<figure><img src="https://lh7-us.googleusercontent.com/XyhD-qUkcwxk8A-waQzhVx78YvaHyuiGF-bgbcSCLvHB8iS0qHLJ2kBcF8xtkAyy-Js7qVGAoNYTBdKUqa5WKo5Q_jArvmMdiDeBu6LMxIcbLVwmCk5mJX0iaFkVUc91dF_GdeN5MNOrL0TuDC6HVqs" alt=""><figcaption></figcaption></figure>

<img src="https://lh7-us.googleusercontent.com/C4bido-oRN58vD9FUNdc-IwW7G0BydJkZnsvWSFKHPRVSlVK8dAF_ZyBWmp4KwVvuaJrvKMa1reyiuiLW6rOu9qEyvzpvVljg4tuxbI2HiKsJAFU7WUnETSc2SYW8ait_nNORnirHVK3BMbt0ywtO10" alt="" data-size="line">

```d
// Cutting Tool
cuttingTool = Surface.ByLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool, Color.ByARGB(200,190,190,190));

// Trim Solid
trimmedSolid = Solid.Trim
	(mass,
	cuttingTool,
	Point.ByCoordinates(20,50,20));

// Color Solid
GeometryColor.ByGeometryColor(trimmedSolid,
Color.ByARGB(255,225,185,145));
```

#### Iteration

Further design development could involve geometry analysis and creation based on solids, faces, curves, points or normals obtained as a result of prior operations.

<br>

We could get the roof as a Surface by Intersecting instead of Slicing and Trimming and then extrude them along their corresponding normals to obtain something that is more than just an extrusion of the original building mass footprint.

<br>

<figure><img src="https://lh7-us.googleusercontent.com/0SmLji_w30YYPL7R_9LuUbrvXc0MtiCr9DGDyNH-53jA5x1UFXSZhNA5z8bT7zlDB7z1m27dUeGcrmdLr_uY3DDfyD9OXMJUhODJjV-YZCIOOcq_LwF022LDnSUXgWP1Wxi8ApbJO8lbm05lkFu1IAo" alt=""><figcaption></figcaption></figure>

![](https://lh7-us.googleusercontent.com/xvE2Rc5XVL_W6Mb94x9S3H1qv4u71w_l9M8BWUhJ0yck7gdgzAwrqrZ5d3Fc7zjN8KMbuYzNKRPot_CjAH9PdvxD6nUk8PwYjFElbflj4USd_E9ex8tS_obEVNMf1HeBBM4NEMIOWNzqOHDpkLnYKKk)![](https://lh7-us.googleusercontent.com/cIbJHe1w2P87T9oKr8dHcLf6VS4mZSpRQGkfWAvJKNhJiy3hOJAgSzujNb8r7rJ_bcVxMZ2blUR8MzUwBDbd56c3y9ADZmeTV5LzmHuVMs_e1qxsOajfeezmG8L5dkBz1cW9dt6Dv661kpq8shV1jao)

<img src="https://lh7-us.googleusercontent.com/vGnpFiOuz8itLCEshd1crgvJ5l6_DUN5DqaV6aJfoiKCJPImEJFoO667sdAAXMcnvCe5UnywUg9tQo91MspbB6VK-a80F44iQ9KrNj7Yi8NCuf5EJmmjEJ-yyR7iM4-_5HrckPO2nBkU7ammBLj7qko" alt="" data-size="line">

```d
// Cutting Tool
cuttingTool = Surface.ByRuledLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool, Color.ByARGB(200,190,190,190));

// Top Surface
massExtents = mass.Intersect(cuttingTool);

// Thicken Surface
massThicken = massExtents.Thicken(-50,false);

// Trim Solid
trimmedSolid = Solid.Trim
	(Solid.ByUnion(massThicken),
	Plane.XY(),
	Point.ByCoordinates(20,50,-20));

// Color Solid
GeometryColor.ByGeometryColor(trimmedSolid,
Color.ByARGB(255,225,185,145));
```

<figure><img src="https://lh7-us.googleusercontent.com/-iHFRgCEMcynldXgTgqU_z1SFxzG4LJsktb_tWQ5tQp40C2STxSoIfLcSfBXMJZfLHPsnaNOb5Dc2vFCM2MwlybNFnR2e0B3B11TOoYgMOG6UnAce4nvC76ROfP3hIFkHYSvsO1uyVcywEBMqbTQHlc" alt=""><figcaption></figcaption></figure>

<div><figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FL9Gqe5dRyFLb1XBxYeci%2F16.png?alt=media&amp;token=1d286b99-7dc7-4f36-a120-7218cb577265" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FBCNpOXqsAOzQJ58tqyor%2F17.png?alt=media&amp;token=8eb9ba4b-ad6e-4364-8397-55ac553a3ae3" alt="" width="375"><figcaption></figcaption></figure></div>

<img src="https://lh7-us.googleusercontent.com/S_aJPcWh911vP8fQNMtt0pfoh0ddR7bNhlh9qqeaKckeVQUD0EOv62EDt3xGrc2VpOhD9pAHJXdVHnHeWJQLhfusyxTr5jctoSm1b8-mmIL3RbNs2oYGs8ZsZhWbFnN5b4GifCm-mov-CK6sDmUGSQo" alt="" data-size="line">

```d
cuttingTool = Surface.ByLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool, Color.ByARGB(200,190,190,190));
massIntersect = mass.Intersect(cuttingTool)[0];
perimeterCrvs = massIntersect.PerimeterCurves();
perimeterPnts = Curve.PointAtParameter
	(perimeterCrvs<1>,(0..0.3..#10));
perimeterNrmls = Surface.NormalAtPoint
	(massIntersect,perimeterPnts)
	.Reverse();
projectedPnts = Point.Project
	(perimeterPnts, Plane.XY(), perimeterNrmls);
projectedLins = Line.ByStartPointEndPoint
	(perimeterPnts,
	List.Flatten(projectedPnts<1>,-1));
projectedSrfc = Surface.ByLoft(projectedLins);

polySrfc = PolySurface.ByJoinedSurfaces(
List.Flatten([massIntersect,projectedSrfc],-1));

GeometryColor.ByGeometryColor(polySrfc,
Color.ByARGB(255,225,185,145));
```

#### Conclusion

Once the initial massing and overall design direction have been established, computational tools can be further utilized to delve into the finer details of the design process. Here's how this iterative approach could unfold:

1\. Division into Functional Sub-volumes: Computational algorithms can be employed to divide the enclosed volumes into functional sub-volumes based on programmatic requirements and spatial relationships. This process takes into account factors such as room sizes, adjacency preferences, and circulation patterns.

2\. Analysis of Circulation, Lighting, and Ventilation: Computational simulations can be conducted to analyze circulation patterns within the space, ensuring efficient movement between rooms and areas. Lighting and ventilation analyses can also be performed to optimize natural light penetration and airflow distribution within the building, enhancing occupant comfort and energy efficiency.

3\. Creation of Openings and Apertures: Based on the results of the analysis, computational algorithms can generate openings such as doors, windows, and other apertures in strategic locations within the building envelope. These openings are placed to facilitate desirable views, maximize daylighting, and promote natural ventilation while maintaining the overall integrity of the design.

4\. Iterative Viewing Exercises: After creating openings and apertures, designers can conduct iterative viewing exercises from each aperture to assess the visual connections, sightlines, and framing of surrounding views. This process allows for refinement and optimization of the building's orientation and fenestration to capture desired vistas and enhance the overall spatial experience.

By employing computational tools throughout the design process, architects can iteratively refine their designs, optimize performance criteria, and create spaces that are not only functional and efficient but also responsive to their context and users' needs. This integrated approach fosters innovation and enables designers to explore new possibilities in architectural design.

{% file src="/files/m8mffnQu4r6C2zbOzzJQ" %}
Dynamo 3.1.0.X
{% endfile %}

<figure><img src="https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ld8QK19sjP1I9rhLouo%2Fuploads%2FLz8RMmLedICEP8nzoIK3%2F07-Code.png?alt=media&amp;token=a5ad633d-adbb-4b95-b1fb-dab0cc9d4d2e" alt=""><figcaption></figcaption></figure>

```d
// Peak
height = 30;
coneStart = Point.ByCoordinates
(0,0,0);
coneEnd = Point.ByCoordinates
	(0,0,height);
peak = GeometryColor.ByGeometryColor
	(Cone.ByPointsRadius
	(coneStart, coneEnd, 25),
	Color.ByARGB(255,55,60,55));


// Coastline
coast = PolyCurve.ByPoints
	(Point.ByCoordinates
		([50,70,90,60,50,30,0,-50],
		[-50,0,25,50,80,60,70,50]));

// Base
base = PolyCurve.ByPoints
	(Point.ByCoordinates
		([50,70,90,60,50,30,0,-50,-50],
		[-50,0,25,50,80,60,70,50,-50]),
		true)
	.ExtrudeAsSolid(0.35);
baseClrd = GeometryColor.ByGeometryColor
	(base,Color.ByARGB(255,200,200,135));

// Water
water = GeometryColor.ByGeometryColor(
	Surface.ByLoft(
		[coast,coast.Offset(300)]),
		Color.ByARGB(50,75,205,235));

// Builing Mass
site = Rectangle.ByCornerPoints
	(Point.ByCoordinates
		([20,20,50,50],
		[50,30,30,50]));
mass = site.ExtrudeAsSolid(20);

// Color Solid
GeometryColor.ByGeometryColor(mass,
Color.ByARGB(255,225,185,145));
GeometryColor.ByGeometryColor(coast.Extrude(0.5).Thicken(0.5),
Color.ByARGB(255,0,0,255));

// Sight Lines
eye = coneEnd;
coastVertices = coast.Points;
sightLines = Line.ByStartPointEndPoint
	(eye, coastVertices);

cuttingTool = Surface.ByLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool, Color.ByARGB(200,190,190,190));
massIntersect = mass.Intersect(cuttingTool)[0];
perimeterCrvs = massIntersect.PerimeterCurves();
perimeterPnts = Curve.PointAtParameter
	(perimeterCrvs<1>,(0..0.3..#10));
perimeterNrmls = Surface.NormalAtPoint
	(massIntersect,perimeterPnts)
	.Reverse();
projectedPnts = Point.Project
	(perimeterPnts, Plane.XY(), perimeterNrmls);
projectedLins = Line.ByStartPointEndPoint
	(perimeterPnts,
	List.Flatten(projectedPnts<1>,-1));
projectedSrfc = Surface.ByLoft(projectedLins);

polySrfc = PolySurface.ByJoinedSurfaces(
List.Flatten([massIntersect,projectedSrfc],-1));

GeometryColor.ByGeometryColor(polySrfc,
Color.ByARGB(255,225,185,145));


//
// Faceted Trim
//
// Cutting Tool
cuttingTool1 = Surface.ByRuledLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool1, Color.ByARGB(200,190,190,190));

// Trim Solid
trimmedSolid1 = Solid.Trim
	(mass,
	cuttingTool1,
	Point.ByCoordinates(20,50,20));

// Color Solid
GeometryColor.ByGeometryColor(trimmedSolid1,
Color.ByARGB(255,225,185,145));


//
//Smooth Trim
//
// Cutting Tool
cuttingTool2 = Surface.ByLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool2, Color.ByARGB(200,190,190,190));

// Trim Solid
trimmedSolid2 = Solid.Trim
	(mass,
	cuttingTool2,
	Point.ByCoordinates(20,50,20));

// Color Solid
GeometryColor.ByGeometryColor(trimmedSolid2,
Color.ByARGB(255,225,185,145));


//
//Faceted Surface
//
// Cutting Tool
cuttingTool3 = Surface.ByRuledLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool3, Color.ByARGB(200,190,190,190));

// Top Surface
massExtents3 = mass.Intersect(cuttingTool3);

// Thicken Surface
massThicken3 = massExtents3.Thicken(-50,false);

// Trim Solid
trimmedSolid3 = Solid.Trim
	(Solid.ByUnion(massThicken3),
	Plane.XY(),
	Point.ByCoordinates(20,50,-20));

// Color Solid
GeometryColor.ByGeometryColor(trimmedSolid3,
Color.ByARGB(255,225,185,145));


//
//Smooth Surface
//
cuttingTool4 = Surface.ByLoft
	(sightLines);
GeometryColor.ByGeometryColor(
	cuttingTool4, Color.ByARGB(200,190,190,190));
massIntersect4 = mass.Intersect(cuttingTool4)[0];
perimeterCrvs4 = massIntersect4.PerimeterCurves();
perimeterPnts4 = Curve.PointAtParameter
	(perimeterCrvs4<1>,(0..0.3..#10));
perimeterNrmls4 = Surface.NormalAtPoint
	(massIntersect4,perimeterPnts4)
	.Reverse();
projectedPnts4 = Point.Project
	(perimeterPnts4, Plane.XY(), perimeterNrmls4);
projectedLins4 = Line.ByStartPointEndPoint
	(perimeterPnts4,
	List.Flatten(projectedPnts4<1>,-1));
projectedSrfc4 = Surface.ByLoft(projectedLins4);

polySrfc4 = PolySurface.ByJoinedSurfaces(
List.Flatten([massIntersect4,projectedSrfc4],-1));

GeometryColor.ByGeometryColor(polySrfc4,
Color.ByARGB(255,225,185,145));
```


# Design Script's ambiguous and versatile Replication Guides <1>

Here we will explore the role that Replication Guides play in building *associations* between elements while using [*Design Script*](https://primer.dynamobim.org/07_Code-Block/7_Code-Blocks-and-Design-Script.html) in [*Dynamo*](https://dynamobim.org/) Code Blocks.

While I've been fascinated by the magic of replication guides for many years now, I haven't really attempted to explain it's workings to even myself. I've got it to work mostly by intuition and many a time by trial and error. However, I'm going to pretend like I know what I'm talking about and invite you to participate in this charade.

<figure><img src="https://media.licdn.com/dms/image/C5612AQFeXnvHHqQ0QA/article-inline_image-shrink_1500_2232/0/1610602383787?e=1717632000&#x26;v=beta&#x26;t=RJ_RHkQxG9Z8DmCbir3oFFt_-jBiW3Z6p5ao2vci7jQ" alt="No alt text provided for this image"><figcaption></figcaption></figure>

The curtains rise and **I** *(a)* am deep in thought, seated at a table.

Kindly note that the colorful sliced sandwiches that make their appearance from time to time, however appetizing they might seem, are only props.

<figure><img src="https://media.licdn.com/dms/image/C5612AQFjF04uH3PZNg/article-inline_image-shrink_1500_2232/0/1610011738650?e=1717632000&#x26;v=beta&#x26;t=JccCWykzqVgqztyPoExdvinaDZ5xKOqu-BfGPKo0MnU" alt="Sandwich graphics illustration"><figcaption></figcaption></figure>

<figure><img src="https://media.licdn.com/dms/image/C5612AQExL2Ks4k_OwA/article-inline_image-shrink_1500_2232/0/1610169939304?e=1717632000&#x26;v=beta&#x26;t=9DeVYHU9s-E4ssPgZWalYHP2QAJCHut3G4E4O1uk_r0" alt="Design Script in Dynamo Code Block"><figcaption></figcaption></figure>

Contemplating.

**I** *(a)* am *Thinking* *(1)*

A + B = **I** *Thinking*

<br>

Apparent and straight forward so far, I suppose. But what am I thinking?

<figure><img src="https://media.licdn.com/dms/image/C5612AQF1QyPncmu-IQ/article-inline_image-shrink_1500_2232/0/1610165475092?e=1717632000&#x26;v=beta&#x26;t=PNFxQ90F9_f01cgFKkymzbfOMrKnhqGwmCYj8uStFh0" alt="Sandwich Graphic Illustration"><figcaption></figcaption></figure>

Pleasant Thoughts.

**I** *(a)* am *Smiling* *(2)*

A + B =

**I** *Thinking,* **I** *Smiling*

Still fairly apparent, I hope.

The *Thinking* *(1)* **I** *(a)* am now joined at the table by a *Smiling* *(2)* **You** *(b)*.

<figure><img src="https://media.licdn.com/dms/image/C5612AQGrdbtX4QcAGQ/article-inline_image-shrink_1500_2232/0/1610297816585?e=1717632000&#x26;v=beta&#x26;t=hhTVBI4TkcCU4ZwD9UgkxqMQD1lxjfH6ObmDoxK-h5Q" alt="Design Script in Dynamo Code Block"><figcaption></figcaption></figure>

Interrupted ? Maybe not.

A + B =

**I** *(a)* *Thinking* *(1),* **You** *(b) Smiling* *(2)*

<figure><img src="https://media.licdn.com/dms/image/C5612AQF2OiMOJbepfQ/article-inline_image-shrink_1500_2232/0/1610011871016?e=1717632000&#x26;v=beta&#x26;t=kWKRW8gurF9C-8TupL57jM6zvVELw7FqTEHKDQ3jYtA" alt="Sandwich Graphic Illustration"><figcaption></figcaption></figure>

But the *Thinking* **I** and the *Smiling* **You** aren't being adequately expressive. While **I** might be pleased with **You** joining the table and probably still *Smiling*, it isn't explicitly represented above. The stage is now set for our protagonist to make an entry and make such associations possible.

#### Replication Guides < > <a href="#ember1537" id="ember1537"></a>

<figure><img src="https://media.licdn.com/dms/image/C5612AQHpoOLw0LtRqA/article-inline_image-shrink_1500_2232/0/1610303806228?e=1717632000&#x26;v=beta&#x26;t=V_uOzQQsHZbFuI87Qi4Nwm_ILjxQiAQ1iajL0_sGrRg" alt="Design Script in Dynamo Code Block"><figcaption></figcaption></figure>

A <1> + B =

**I** *(a)* *Thinking* *(1),* **I** *(a)* *Smiling* *(2)*

**You** *(b)* *Thinking* *(1),* **You** *(b) Smiling* *(2)*

<figure><img src="https://media.licdn.com/dms/image/C5612AQFkHY7vc_dpDw/article-inline_image-shrink_1500_2232/0/1610302678145?e=1717632000&#x26;v=beta&#x26;t=H6XFrHJKrd2NEbAb38KrMh-l3geFXHEPFXFEcb-mpvA" alt="Sandwich Graphic Illustration"><figcaption></figcaption></figure>

Introducing <1> after A, pairs each element of A with every element of B. If it follows B instead, the structure of the result is altered. The *Transpose* of the earlier result is obtained.

<figure><img src="https://media.licdn.com/dms/image/C5612AQEVY2iplIezMw/article-inline_image-shrink_1500_2232/0/1610303842107?e=1717632000&#x26;v=beta&#x26;t=konZSFnHY70qwp-oP6TwEs9hWm6uHn-35vgXBXEVTr0" alt="Design Script in Dynamo Code Block"><figcaption></figcaption></figure>

A + B <1> =

**I** *(a)* *Thinking* *(1),* **You** *(b)* *Thinking* *(1)*

**I** *(a)* *Smiling* *(2),* **You** *(b)* *Smiling* *(2)*

<figure><img src="https://media.licdn.com/dms/image/C5612AQGCX_ggGqai4w/article-inline_image-shrink_1500_2232/0/1610011939973?e=1717632000&#x26;v=beta&#x26;t=Gx3Sb9rTXPHZbEymi3nRbE6NT7RwcrBO5LjMFys5BGE" alt="Sandwich Graphic Illustration"><figcaption></figcaption></figure>

Lots of thinking and smiling, but to what end? The objective of such an exercise is to extract a selected few sandwiches from a generated stack of sandwiches while always trying to minimize the size of the overall sandwich stack from which the few are extracted.

We are now joined on stage by a *Sitting (3)* **Cat** *(c)* and a *Standing (4)* **Dog** *(d)* and that could mean more sandwiches.

```
A + B
```

<figure><img src="https://media.licdn.com/dms/image/C5612AQHSPs_VFE-A0w/article-inline_image-shrink_1500_2232/0/1610374023262?e=1717632000&#x26;v=beta&#x26;t=5VwqcYC_jIYzUF94_f3tYypBqTLgaTSnTihBVRev9wI" alt="Sandwich Graphic Illustration and Dynamo Graph"><figcaption></figcaption></figure>

<figure><img src="https://media.licdn.com/dms/image/C5612AQFASGxsu1HaBg/article-inline_image-shrink_1500_2232/0/1610601543943?e=1717632000&#x26;v=beta&#x26;t=0y8LUOEoAWvhp6hbOeMo_npIAU0_RDuqsn9mg7CKHMU" alt="His Masters Voice logo. Jack Russel terrier listening to a gramaphone"><figcaption></figcaption></figure>

**I** *(a)* imagine the **Dog** *(d)* to be Nipper, the Jack Russel Terrier from 'His Master's Voice' and that puts a smile on my face.

We would now need a *Sitting (3)* **Dog** *(d)* and *Smiling (2)* **I** *(a)* to capture this picture. That means, even more sandwiches.

<br>

```
A <1> + B  and  A + B <1>
```

<figure><img src="https://media.licdn.com/dms/image/C5612AQFV2xhJxFImkw/article-inline_image-shrink_1000_1488/0/1610374589075?e=1717632000&#x26;v=beta&#x26;t=lTEe_qZCOTSvhyhZW8XIQrV83KceRe8kYUVT05_6gFo" alt="Sandwich Graphic Illustration and Dynamo Graph"><figcaption></figcaption></figure>

So far, **You** *(b)* and **I** *(a)* have been in a world separate from the **Cat** *(c)* and **Dog** *(d)*. Our activities and emotions seem to be mutually exclusive. But Nipper is a *Thinking* *(1)* **Dog** *(d)* and **You** *(b)* are *Sitting (3)*, probably bored and exhausted by no&#x77;*.* To capture this we would need to bridge the two worlds with a chain (*<1><2>*) of Replication Guides.

```
A <1> <2> + B   and   A + B <1> <2>
```

<figure><img src="https://media.licdn.com/dms/image/C5612AQFbop3Po6Psnw/article-inline_image-shrink_1000_1488/0/1610425403157?e=1717632000&#x26;v=beta&#x26;t=6jN_U3sfkjbLjmDxnZsXe_P2uE3gRM7DYNQAR1qxu7w" alt="Sandwich Graphic Illustration and Dynamo Graph"><figcaption></figcaption></figure>

We could take this further (and further more). Imagine **You** and **I** are out on the streets, walking our **Cat** and **Dog**. We *Smilingly* greet others (**Him, Her, Them**) who are also enjoying the pleasant weather *Sitting* on benches, maybe.

With some orderly selection and grouping we should be able to intelligibly capture all this. Identifying, Capturing and Organizing data would be the first step (there could also be sleeping monkeys or frowning people present, but they are of no interest to us and will be ignored), followed by optimally obtaining combinations with Replication Guides (with a longer chain *<><><>* maybe) and filtering out those undesired.

Lets hope all involved behave as expected and the weather remains pleasant. Unpredictable behavior, like unpleasant weather can cause chaos.

<figure><img src="https://media.licdn.com/dms/image/C5612AQHp6BE5KlO5Tg/article-inline_image-shrink_1000_1488/0/1610606894402?e=1717632000&#x26;v=beta&#x26;t=EcSX03ULaOhTdiLnqN2HcuuGmvSNH5Skz1aMxd6tTnY" alt="Very unpleasant Weather, painting by George Cruikshank. Raining cats, dogs and pitch forks"><figcaption></figcaption></figure>

I'll bring down the curtains on this explanation of my understanding of one aspect (association) of Replication Guides with a word of caution. While numerous combinations will be possible with different configurations of Replication Guides (which might be good to explore and go overboard with while getting a grasp of the concept and its workings), it would be wise to eventually keep it as simple as possible and avoid unnecessary depth and complexity by first cleaning up and properly organizing the initial inputs.


# Design Script's ambiguous and versatile Replication Guides <2>

When it was raining cats and dogs [earlier](https://www.linkedin.com/pulse/design-scripts-ambiguous-versatile-replication-guides-vikram-subbaiah/), I didn't bother clarifying that drops of water were pouring down from the skies and that canines or felines weren't involved. However, if I were to be addressing a universal audience, I might need to be sensitive to alternate possibilities (beyond [amphibious rain](https://science.howstuffworks.com/nature/climate-weather/storms/rain-frog.htm), literally) and ensure further clarity.

I'm actually alluding to an audience that includes inter galactic travelers familiar with Diamond rain on Saturn where crystallized carbon falls like tiny diamonds, Sulfuric Acid raining on Venus, Dry Ice snow on Mars and Liquid Helium rain on Jupiter.

<figure><img src="https://media.licdn.com/dms/image/C5612AQEJI5INDepaag/article-inline_image-shrink_1500_2232/0/1611513763073?e=1717632000&#x26;v=beta&#x26;t=RHj5m6viNsAm9FwXI9nOUh_P-KTWhvb-Z_M3imj9Wec" alt="Diamond boiling"><figcaption></figcaption></figure>

Diamonds? Lets get them.

But they need cleaning

Boiling diamonds in acid is one way of cleaning them. We will need sulfuric acid.

So we get rid of unwelcome dry ice from Mars and helium from Jupiter to be left with Diamonds from Saturn, Sulfuric Acid from Venus and Water from Earth.

Sounds like a plan.

We could go about this in two ways : Get rain from a list of planets and select the desired ones *or* Short list the eligible planets and get only their rain.

<figure><img src="https://media.licdn.com/dms/image/C5612AQG0-WYHY5GaQA/article-inline_image-shrink_1500_2232/0/1611514492941?e=1717632000&#x26;v=beta&#x26;t=-_XwD07YQdB6d2K2KdmZRkZBTwiZvAjhxvTO4FYN-rI" alt="No alt text provided for this image"><figcaption></figcaption></figure>

<figure><img src="https://media.licdn.com/dms/image/C5612AQEtl2EcEndrzg/article-inline_image-shrink_1500_2232/0/1611556370361?e=1717632000&#x26;v=beta&#x26;t=Ly1Tv9WtI1PEdYJcxjTdtdyP2DtVHJ5PWPO9okHHZck" alt="No alt text provided for this image"><figcaption></figcaption></figure>

Do note the use of *Replication Guides* (*< >*) to *access* elements at sub list level.

But it isn't just the planets, it rains on some moons too. There are icy methane rainstorms on Titan, Saturn's largest moon. Titan has a methane cycle similar to our water cycle.

Lets compile a list of the planets in our solar system along with their moons . Planets like Jupiter (79) , Saturn (82), Uranus (27) and Neptune (14) have numerous discovered (so far) moons. For the sake of brevity we will only limit our consideration to a few of their moons.

<figure><img src="https://media.licdn.com/dms/image/C5612AQGPHG7dmXt97g/article-inline_image-shrink_1500_2232/0/1611556586873?e=1717632000&#x26;v=beta&#x26;t=4q07S_LsoQqgu2QJf6mRcmD8OdkdtukjPQgMPmud0_M" alt="No alt text provided for this image"><figcaption></figcaption></figure>

<figure><img src="https://media.licdn.com/dms/image/C5612AQH43cmwD2mEIQ/article-inline_image-shrink_1500_2232/0/1611556675975?e=1717632000&#x26;v=beta&#x26;t=bq7_Ml0YfY1o7Bje-NvUFj9xr7L1Tu-L_ZTLuqyqosQ" alt="No alt text provided for this image"><figcaption></figcaption></figure>

Many planets have multiple moons and they would need to be contained within sub-lists that are accessed using replication guides.

Planets that have no moons are not ignored, empty lists indicating their absence ensures consistency in sub-list structure. The content is extracted irrespective of quantity.

Beyond the first four rocky planets, the gaseous Jupiter & Saturn and the icy Uranus & Neptune there are the dwarf planets which, besides Pluto (which was classified as such on August 24, 2006), so far includes Ceres, Makemake, Haumea and Eris. The planet list structure gets another level on including the dwarf planets and accessing the moons of all planets will require a chain of replication guides *<1><2>*.

<figure><img src="https://media.licdn.com/dms/image/C5612AQEh_B8sI7EB8w/article-inline_image-shrink_1500_2232/0/1611557556216?e=1717632000&#x26;v=beta&#x26;t=Tv08TvTRUx2RlC_zGoMM1WC_v5rVyBfezLTftezXEpw" alt="No alt text provided for this image"><figcaption></figcaption></figure>

<figure><img src="https://media.licdn.com/dms/image/C5612AQGvyj4etwTDUw/article-inline_image-shrink_1500_2232/0/1611558216085?e=1717632000&#x26;v=beta&#x26;t=4ThjtqnmWr3HRD4oU3lkDs78mjxxgztb29zPN1QChL0" alt="No alt text provided for this image"><figcaption></figcaption></figure>

The chain of replication guides could get even longer as the level that needs to be accessed gets deeper. Like if other planetary systems, are to be considered or if precipitation on other moons is of interest. By the way, snow on Io (Jupiter) is yellow and snow on Triton (Neptune) is pink.

Now that we can use replication guides to *access* targeted levels, we are better equipped to take on the universe than the inter galactic visitors, camping on Mars, who are still struggling to figure out the correct combination of replication guides that would enable adding us, the shining bright star in the Martian night sky, to their shopping list of planets.

<figure><img src="https://media.licdn.com/dms/image/C5612AQHLazIqEftohA/article-inline_image-shrink_1000_1488/0/1611495273043?e=1717632000&#x26;v=beta&#x26;t=l3ZmLv90ZfsFOFzRWSbfdmatZiUEIZmzyLwtIrxWKtk" alt="Earth from Mars"><figcaption></figcaption></figure>

Credit: NASA Jet Propulsion Laboratory-Caltech/Malin Space Science Systems/Texas A\&M University. Source: [NASA Jet Propulsion Laboratory](http://www.jpl.nasa.gov/news/news.php?release=2014-039).

#### Sources <a href="#ember1992" id="ember1992"></a>

Alison Cooper, "Does it rain on other planets?" 3 September 2014. HowStuffWorks.com. <[https://science.howstuffworks.com/rain-other-planets.htm>](https://science.howstuffworks.com/rain-other-planets.htm>) 24 January 2021

NASA Science, Solar System Exploration <[https://solarsystem.nasa.gov/>](https://solarsystem.nasa.gov/>) 24 January 2021

"Boiling Diamonds" <[https://en.israelidiamond.co.il/wikidiamond/terms-attributes-the-diamond/boiling-diamonds/>](https://en.israelidiamond.co.il/wikidiamond/terms-attributes-the-diamond/boiling-diamonds/>) 24 January 2021


