Grasshopper: Visual Scripting for Rhinoceros 3D. David Bachman

Чтение книги онлайн.

Читать онлайн книгу Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman страница 6

Автор:
Жанр:
Серия:
Издательство:
Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman

Скачать книгу

Interpolated lines through a list of lists of points.

      Sometimes a data tree is not organized correctly. In some cases you will want to restructure the data into a new list of lists where the first list consists of the first elements of the original data tree, the second list comes from all the second elements, etc. This can be accomplished with the Flip Matrix component (Set tab, Tree panel). The effect is shown in Figure 2.9.

img

      We use this idea to create an interesting family of curves on a torus. Consider the script of Figure 2.10. The script begins with a simple Circle component (Curve tab, Primitive panel). Here the R (Radius) input has been set to the value 2. Next, we pass to a Perp Frames component (Curve tab, Division panel) to create a list of 10 planes perpendicular to the original circle (more on this component in Chapter 4). These planes are then given to another Circle component, creating 10 smaller circles or radius one, with one circle in each plane. Each of these circles is sent to a Divide Curve component (Curve tab, Division panel), which creates a list of 10 points on each curve. At this point we have 10 lists of 10 points. The first list is comprised of the points on the first circle, the second list are the points on the second circle, etc.

img

      If we were to send this data tree directly to an Interpolate component the result would be the same 10 circles of radius one. To create the more interesting set of curves shown in the figure, we first use the Flip Matrix component before passing the data tree to the Interpolate component.

       Adding More Interactivity

      In previous chapters we saw how to make your Grasshopper scripts interactive by using a number slider. However, this is just one way in which a user can interact with a script. For example, one can use a Control Knob (Params tab, Input panel) in place of a slider to simulate setting a dial. However, this is really just an alternate way to do the same thing.

      The number slider itself is an extremely versatile component. As we have seen, some components expect a real number input, such as the R input (radius) of the Circle component. Others expect a natural number as an input, such as the N input of the Range component. Sliders can be used at those inputs, too, by right-clicking on them and changing the “Slider type” to “Integer.” For example, examine the simple script depicted in Figure 3.1. The output of the slider determines the number of real numbers that the Range component will pick in the given domain. These numbers are then passed to the X input of a Construct Point component.

img

      Another useful way to interact with a Grasshopper script is with the Graph Mapper component (Params tab, Input panel). Examine the script depicted in Figure 3.2. This script creates 10 circles at different heights, parallel to the XY-plane, and lofts them. The radius of each circle is determined by a function depicted right on the Graph Mapper component. When you right-click on this component, you’ll have the choice of a variety of different types of functions under the “Graph types” submenu. Each such function is marked with a few white dots that determine its shape. Moving these dots around changes the function, and therefore the final output geometry. One can see the effect of this in Figure 3.3.

img img

      For a different way to interact with Grasshopper, try building the script depicted in Figure 3.4. The Series components (Set tab, Sequence panel) in this script are each outputting the list of numbers 0,1,2,...,9. These are both fed into a Construct Point component, with the second one grafted, thereby creating a 10-by-10 grid of points. The Point component toward the bottom of the script is referencing the highlighted point in the Rhino viewport, defined by right-clicking on the component and selecting “Set one Point.” Both the grid of points and this individual point are fed into a Distance component (Vec tab, Point panel), which measures the distance between the chosen point and each point of the grid. Finally, these distances are used as the radii of circles, centered at each grid point.

img

      To reveal the interactive nature of this script, make sure the Point component is selected, and move the referenced point around in the Rhino Top viewport. You’ll notice the pattern of circles changes dramatically as you move it. See Figure 3.5. In a similar way, any Rhino geometry can be used as the basis for an interactive Grasshopper script. Creating a curve in Rhino, and referencing that curve by right-clicking on the C input of a Pipe component, creates a surface. Modifying the curve in Rhino (by turning “Points on,” for example) will cause Grasshopper to modify the resulting surface.

img

       Curves and Surfaces

Скачать книгу