29th February 2024

GHEC 02 : Why & How to Think Algorithmically

Today's focus

  • Modelling a Twisting Tower
  • Homework to complete before the next session

The Twisting Tower

Our exercise today involves a classic Grasshopper creation: the twisting tower. Despite its cliché status, it's an excellent entry point into algorithmic thinking. Let's first take a look at the steps it takes to create this model.

Pasted image 20240202094047.png

We are going to see how to implement this in Grasshopper. I hope you will follow along with me. Open up Grasshopper, and let's begin.

Creating the Ground floor

We are going to start by creating the ground floor with a rectangle. The good news is, you don't have to go through the same trouble as you did in the homework, Grasshopper comes with a rectangle component.

Pasted image 20240116105312.png

Let's pause here and talk about the inputs to this component. The rectangle component takes in two domains that let you control the height and the width of the rectangle.

A domain is just a range of numbers, think 0 to 100 or -10 to 10. You can make a domain with a panel or you can use the construct domain component.

To use the panel, simply type "X to Y" where X is your first number and Y is your second number.

Depending on your unit settings, you might see a huge plane. Just preview off the rectangle and plug a curve container into the output.

Pasted image 20240116105415.png

Note: to preview off, just select your components, right-click on an empty spot on the canvas, and then choose preview on/off.

Pasted image 20240116105312.png

Now, that we have our ground floor, let's move to creating the rest of them.

Creating the other floors

We can do this by moving the ground floor up several times.

To do that, I am going to use the range component. This component takes in a domain and a step number and gives a list of numbers evenly spread within the given domain.

The idea is that we can give the height of the tower and the number of floors and the range component can create our floor elevations.

Pasted image 20240116105813.png

Note: Notice how Grasshopper gave me 16 numbers instead of 15, this is because the Range component will always include the last number of the domain.

The Slider Component

Now, we have seen that we can easily update the model by changing out inputs. So, if the number of floors is something that I want to change often, I don't want to enter a number every time. I want something easier. To get that, I'll use a slider instead of a panel for quicker editing.

Once you have found the slider component through the toolbar or the search bar. Double-click on the component, to get it's settings.

Pasted image 20240116112544.png

Note: As a search bar shortcut, you can also type in "0<10<15" which will make a slider from 0 to 15 and put 10 in as its current value. This is a lot faster than using the window

Changing Slider.gif

Because Grasshopper re-solves the canvas every time something changes, you can see that the list of numbers changes as I play around with the slider.

Back to Floors

Since we have our list of floor elevations, we can use the move component to move our ground floor. By default, upwards is in the Z-direction, which means I'll use the Unit Z Vector component.

Pasted image 20240116113424.png

Note: Remember to switch to Perspective mode to see the entire tower

Adding rotation

With our floors created, we can now rotate them to get that "twist" effect. We can do this with a similar process that we used to move the floors.

Again, I'll use a range component to get a list of angles to rotate the floors. I'll make those changes to the script, like so.

Pasted image 20240116134531.png

Alright, a lot of things have happened, let's just pause and talk about it.

1. Overlapping display of floors

If you are following along (which I hope you are), then you might see your floors overlapping in Rhino like this :

Pasted image 20240116134755.png

This happens because Grasshopper preserves and previews every component on the canvas. To only see the rotated rectangles, preview off the move component.

2. Using a slider instead of a panel for the range input

You might have noticed that I am using a slider for the range component instead of a panel. This works because if you pass in any number into a domain, it will automatically create a "0 to X" where X is the number you gave it.

You can see this if you hover over the "domain" input of the range component.

Pasted image 20240116134951.png

I do this because I want to quickly change the angle of rotation of the model.

3. Using Degrees in the rotate component

When you first plug in your angles into the rotate component, you will see that your rotations as weird. This is because you are rotating in radians instead of degrees. To change to degrees, just right-click the angle input and select degrees.

Pasted image 20240116135058.png

Covering the Tower

Now, all that's left to do is to "cover" the tower. This is just for the sake of completeness and to make it look more like a tower than a series of floating rectangles.

To do that, we just need to use the surface and loft components.

And it's as simple as just plugging in the rotated into the components. The surface component will turn the floors into a surface (meaning it won't look hollow, we will talk about geometry types later) and the loft component will join all the floors together creating a surface on the outside of the tower.

Pasted image 20240116135422.png

Final Thoughts

and... that's it! We have just made our first Grasshopper model. Even though it was relatively simple, the process of creating this model is the same as a complex model just with way more steps.

If any part of the process was unclear, I have attached my script below. And remember, I'm also here to answer any questions.

Today's Homework

I have prepared two tasks for you today. I recommend doing at least one task before our next session to help you cement what we have learnt today.

Task 1: Make a double-twisting tower

Now that you have seen first-hand how to make a twisting tower. I want you to try and turn this script into a double-twisting tower. It should look something like this.

Note: This challenge is supposed to be difficult and it's okay to feel frustrated during the process. I'll release the solution in the next session.

Here's a hint to help you out, try moving the base rectangle by some distance in the X or Y direction and watch what happens.

Task 2: Make different-shaped twisting towers

When we made the twisting tower, we used a rectangle as the floor outline but actually, we can use any shape we want. See if you can tweak the script to do this.

Grasshopper has components that create basic shapes. See how many in this list you can use with the twisting tower script.

  • Ellipse
  • Polygon
  • Bonus: Rounded Rectangle (Use the fillet component)

This task is to encourage you to explore Grasshopper's component library. Also, as a bonus, if you finish early and want to do more, try drawing your curve and use that as the floor shape (It's not as easy as it seems).

Resources