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

# Sagrada Familia Schools Roof

<figure><img src="/files/XfX7AkvmFxOsfOy4TwVy" 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="/files/iNAsKHKUe1P8fCRzSud5" 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="/files/UCwynITZt0BPB1WuYdOx" 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="/files/AqQhQ3sX85AMwrmsq9Od" 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="/files/467hTOakein8NWDxUvzc" alt=""><figcaption><p>Step 4 : Nurbs Surface</p></figcaption></figure>

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

<figure><img src="/files/krz6zloOyZ2uu3061VAK" 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="/files/MCSe68NrRAq5pqLbQ3Eo" 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="/files/ynaRUyh3zjIivyAqqWid" 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="/files/wgDH2pyHQKZofJb07yI1" 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);
```
