Join Chris Reilly for an in-depth discussion in this video Checking out transformation basics, part of Up and Running with Grasshopper.
The transform components in Grasshopper, located under the Transform Component tab, are in many ways very similar to those built-in to Rhino. We can do things like Scale, Rotate, Move, and Orient, just to name a few. There are some differences, however, in the way that transformations can happen in Grasshopper that might be new to you. So, let's take a look at a few examples of basic transformations in Grasshopper. We'll start off by looking at the Move component. So this is under the Transform Euclidean Component tab.
So I'll just click and drag that onto the canvas. And, of course, we'll need to give ourselves something to move. I'll make a simple, primitive box using the Center Box component, and that's located under the Surface Primitive Component tab. I'll go ahead and setup some floating point Number Sliders for the X, Y, and Z dimensions. And then, I am just left-clicking and hitting Alt and dragging down to duplicate those. So, now, I've got a box.
Let's make it move. So the Move component takes as it's inputs, a base Geometry and a Motion vector, which determines where that Geometry gets moved to. So I'll connect the center boxes, box output to the Move components Geometry input. And you can see we now have a second box above the first. Unlike in Rhino, a move in Grasshopper always makes a copy of the thing that it's moving, leaving the original in place. Let's take a look at the Motion vector settings. Now, the default vector is 0, 0, 10 or 10 units in the Z direction.
And there are many different ways we could specify what this motion vector is. We could manually define it in Rhino by selecting Set one Vector from the Contextual Menu. And here, I could just click to set where that box ends up. We could also type in one or more vectors by selecting Manage vector collection. And here, I could just click and set the X, Y, and Z values. So maybe, let's say 3, 2, 1. Or, we could connect any component from the Vector > Vector component menu.
So any of these could feed into our translation vector and control where the move ends up. So I'd like to give myself a little bit more flexible way of controlling how this box moves. So, to set that up, I'll first grab the Unit Z component from that Vector > Vector component menu. Just click and drag that onto the canvas. And I'll plug that into the Move component's Motion vector input. So the unit vector is defined as 0, 0, 1, or 1 unit in the positive Z direction. And I can see my duplicate has moved up 1 unit in positive Z.
Now, I can also attach a Number Slider to the unit Z's Factor input and that way my Unit Z vector will be multiplied by the amount of the Number Slider, and I can control how far up my move goes. So just make an integer Number Slider and connect its output to my Unit Z's Factor input. Now, as I dial it up and down, I can control where my move box ends up. Now, let's say that's still isn't quite enough flexibility for me and I want to use the move component to generate multiple copies of my base Geometry, not just one. Now, I can set that up pretty easily using the series component. I'm going to switch back to a file from an earlier chapter where we covered sequences. And I'm going to grab this series setup that I made and just do Edit > Copy, and paste it back into my file. So I can get rid of this Number Slider, and I'll replace the Unit Z's Factor input with the output of my series, which is actually a list of numbers.
So let's see what happens when I do that. All right. Pretty cool. So now I get a series of duplicate boxes. And I can control the quantity and how far apart they are using the controls in my series component. Pretty cool, huh? Let's keep going with this example and look at some ways we can use rotational transformations. Now, there are several different variations of rotation components under Transform > Euclidean, in the Component tabs. The one we'll try first is Rotate Axis. This rotates geometry around an axis. So let's get that onto the canvas. So rotate axis takes three inputs. The first is the Geometry to rotate. The second is the Angle of rotation in radians. And the third is the axis around which the rotations will take place. Now, like the move component, rotate axis creates duplicates of its input geometry. So I'm going to go ahead and connect the Geometry output from my Move to the Geometry input of rotate axis. And after that, I can disable preview on my Move because I'm going to get it duplicates there. So the default rotational axis that's set in rotate axis is not what we want. That's why things kind of get flipped sideways here. I'd like to keep those duplicate boxes in the same vertical orientation that they were before. So, I'm going to right-click on that Axis input and go to Set one line. And I'm just going to set this manually in Rhino. And I'd like to pick a line that's right along the Z axis. So I'm going to turn on my grid snap, make sure I start at the origin, and then switch views to go straight up. Okay. That looks much better. Now to control the angle of rotation, I'll just make a floating point number Slider that ranges between zero and 2 pi. And that'll give me one full rotation to play around with. And I'll plug that right into the Angle input of my rotate axis component. And you'll notice I can scrub the slider back and forth and all of my duplicates rotate. So that's kind of cool. But what if I wanted each duplicate box to rotate differently? Well, just like with the Move component, I can attach a series component to the rotate axis angle input and get a series of unique rotations. So, I'll go ahead. I'm just going to copy this series setup. And I'm left-clicking, and then hitting alt, and just dragging to get a duplicate there. So, for now, I'll just disconnect my angle Number Slider. Just right-click, Disconnect, and I'll plug this series component into the Angle input. There's a couple little housekeeping things I can do here with both of these series components. Now, I know that the count input on both series components should be the same. That's because I'd like a rotation for each one of my duplicates, not any more or less. So I can go head and actually delete this Number Slider, and just do a duplicate connection to the second series. On both of these also, really, I want to make sure that the start and the step are the same. You'll notice here in the one that's controlling the moves, the duplicates, the spacing can get a little bit weird if these are different numbers. So, ideally, I'd like both of these to be set like this should be five right now. That way, I get an even spacing, so I can feed both of these inputs with the same Number Slider. So, again, just do a double connection here. That'll make sure things are spaced evenly. And I'll do the same on my series components that's affecting the rotations. And this time I'll grab that Number Slider that I was feeding the angle width, and connect that both to the start and the step input. Now, I can see as I adjust that, each duplicate box gets rotated differently since, basically, the rotations are sort of compounding as we move up the line of duplicates. Okay. Moving on, let's take a look at the scale component. So that's under Transform > Affine, in the Component panel. Scale, of course, changes the size of geometry, either making it larger or smaller. And the scale component in Grasshopper takes three inputs. First is the base geometry to scale. Second is the center around which scaling takes place. And third is the scaling factor. So how much does the scale get multiplied by basically? So let's go ahead and keep our definition flowing here. So I'm going to connect the geometry that's coming out of our rotate axis component to the geometry input of the scale component. And let's see what happens. Okay. So I can see, again, I get a duplicate set of geometry. So just like all of the other transform components we've looked at here, we have the one set still affirm Rotate Axis and a new set from the Scale components. I'm going to go ahead and turn off Preview from the Rotate Axis component. And just like in the previous example, all of the duplicates are getting scaled by the same factor at this point.
And I could add an additional series here just by copy-pasting. And I could use to give unique scales to each duplicate. And those will plug in to my Factor input of the Scale component. Okay. And I see I get quite a dramatic set of scales here. I think I might want to draw this down just a little bit. So, let's first tackle the Number Slider here. Probably I want this to start at zero. So, that's good. And let's say the max is 3. So we would only scale up to a maximum of three times the, the current scale. Now, there's one additional thing that's unique about the scale component. I can see that I'm also able to scale it down to the point where the second duplicate is inside of the first original based geometry. I don't really want that. That's going to be really confusing. So, I'm going to use a little trick here by right-clicking on a start input of my series component. going to add an expression, and I'm just going to say x plus 1. Now, this might seem a little bit counterintuitive at first, but let's think about what's happening. So the series step input is the number by which we're incrementing the scale after each step. It's not the scale itself. So, if we were to start with a very small scale like 0.125 or, in this case 0.144, the first box in the serial scale would be tiny.
And, like we just saw, it was so small that it was actually inside the base geometry. So we add 1 with that expression to give the baseline scale of that first source geometry. And that looks a little bit more manageable. And I can tweak that if I wanted to and still maintain control over things like the rotation, things like how many duplicates I'm making. And I also still have control over the dimensions of the base box, which cascades out to all the other duplicates no matter where they are. Okay. So those are a few basic methods of using Transforms in Grasshopper.
- What is Grasshopper?
- What's an algorithm?
- Setting input data
- Using data matching
- Looking at mathematical and logical functions
- Analyzing curves and surface data
- Working with transformations
- Manipulating the Data Tree