# Modifying a grid

**URL:** https://discourse.processing.org/t/modifying-a-grid/19298
**Category:** Electronics (Arduino, etc.)
**Created:** [April 1, 2020, 5:47pm UTC](https://discourse.processing.org/t/modifying-a-grid/19298 "2020-04-01T17:47:01Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [April 2, 2020, 12:58am UTC](https://discourse.processing.org/t/modifying-a-grid/19298/4 "2020-04-02T00:58:45Z")

</div>

Hello,

You also posted [here](https://discourse.processing.org/t/how-would-i-modify-this-code-to-change-the-output-of-the-code/19085) looking for a “U instead of flat”.

You were also asked to format your code there as well.

Here is a good reference:  
[https://www.processing.org/examples/shapetransform.html](https://www.processing.org/examples/shapetransform.html)  
[https://processing.org/tutorials/trig/](https://processing.org/tutorials/trig/)

For the L:  
I used 2 loops to draw the grid and swapped the x and z vertex in one of them; you will have to change ranges in the for() loops to get the L.

For the U:  
I added sin() values to the z vertex; I used 0 to 15 \> 0 to PI (mapped or math) … and I took the sin() of that multiplied by an amplitude and added that to z vertex.

You will have to determine a formula for amp to offset the z from 0 to 15.

To get you started with the U (just one loop):

```auto
vertex(vertices[z][x].x, vertices[z][x].y, vertices[z][x].z+amp); 
vertex(vertices[z][x+1].x, vertices[z][x+1].y, vertices[z][x+1].z+amp);

```

And the result of my efforts:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9b69c916e61ec1cd491cca17f49e4e8aebdc6c42.png)

`:)`

---

_[View the full topic](https://discourse.processing.org/t/modifying-a-grid/19298)._
