Golden Gate Bridge

Let's explore some variations of columns to build a Golden Gate Bridge (kind of). If you do not understand the math in the example, you can skip this chapter.

High-low columns

hi_low_10() builds 20 columns in a group: 10 high-to-low and 10 low-to-high columns, for a total of 20 columns:

# 10*2 hi-low columns in red
def hi_low_10():
    for i in range(1, 20, 2):
        column(i, -20, (20-i) , 'red_sandstone')
        column((i+20), -20, i , 'red_sandstone')

hi_low10()            # red, start at x=0

hi_low_s(shift)

Shift the starting location from x = 0 to x = s * 40. You can think of s as 'shift'; s * 40 means each shift is 40 blocks to the right.

# black hi-low columns with s shift
def hi_low_s(s):
    for i in range(1, 20, 2):
        column((i + s*40), -20, (20-i), 'obsidian')
        column((i + 20 + s*40), -20, i , 'obsidian')

# build a set of obsidian columns shifted to x = 40:
hi_low_s(1)

I changed the material to 'obsidian' in order to distinguish from the red.

3 groups of high-low columns

We can build 3 groups of high-low columns, using for loops and hi_low_s(s):
group 1 with shift of 0;
group 2 with shift of 1;
group 3 with shift of 2;

# 3 groups of columns
for s in range(3):
    hi_low_s(s)

You can see the 3 groups of columns are all connected smoothly.

High-low columns with flexible material and z position

Based on our previous work, we can define a variation of hi_low_s that also accepts a z coordinate and a material parameter:

hi_low_col(s, z, m)

def hi_low_col(s, z, m):
    for i in range(1, 20, 2):
        column((i + s*40), z, (20-i), m)
        column((i + 20 + s*40), z, i , m)

Golden Gate Bridge

Build 3 groups of hi_low_col at z=-40, another 3 at z=-20:

for s in range(3):
    hi_low_col(s, -20, 'red_sandstone')
    hi_low_col(s, -40, 'red_sandstone')

Then add a floor board at the base of the structure by calling flat_xz(x,y,z,width,length,material):

flat_xz(1, 1, -40, 20, 60, 'dirt')

Let's take a walk through this bridge!

Snap your fingers, let's cross the bridge to the world of Narnia:

for s in range(3):
    hi_low_col(s,-30, 'ice')
    hi_low_col(s,-10, 'ice')

flat_xz(1, 1, -40, 20, 60, 'Linen_light_blue')

More Practice

hi_low_n(n): n*2 hi_low columns

Based on the first function hi_low_10(), we can define a new function that builds n*2 columns, instead of 10*2: n high-to-low plus n low-to-high.

def hi_low_n(n):
    for i in range(1, 2*n, 2):
        column(i, -20, (2*n-i) , 'box_lime')
        column((i+2*n), -20, i , 'box_lime')

hi_low_n(10)      # same as hi_low_10()

hi_low_n(5)       # group of 5*2

results matching ""

    No results matching ""