Grasshopper: Visual Scripting for Rhinoceros 3D. David Bachman
Чтение книги онлайн.
Читать онлайн книгу Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman страница 8
![Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman](/cover_pre671815.jpg)
FIGURE 4.8. The result of Grasshopper’s Offset Surface component.
FIGURE 4.9. Creating a new surface by offsetting a paraboloid by the square of the sine of the v parameter.
Grasshopper contains many kinds of transformation under the Transform tab. The most mysterious (and useful) of these are the ones that transform geometry onto a surface, similar to Rhino’s Flow along Surface command. In this chapter we describe several such transformations.
In the previous chapter we saw how to get and use the domain of a surface. Here we build upon this idea to show how Grasshopper can be used to define transformations from the domain space to the surface space.
The simplest way to make a given geometry conform to that of a surface is to use the Map to Surface component (Transform tab, Morph panel). This speciality component will take a curve in the domain space of a surface, and return a transformed curve on the surface itself. Consider the script depicted in Figure 5.1.
The script starts with a Cylinder component (Surface tab, Primitive panel). As described in the previous chapter this is fed to a Deconstruct Domain2 component (Math tab, Domain panel) to extract intervals representing the u and v parameters. Each of these intervals is then given to a Rectangle component (Curve tab, Primitive panel) to create a rectangle in the XY-plane that represents the boundary of the domain parameter space of the cylinder.
FIGURE 5.1. A script to create Voronoi cells on a surface.
To create an interesting set of curves to map to the cylinder, we first give this rectangle to a Populate 2D component (Vector tab, Grid panel), which creates a random set of points in the region of the XY-plane bounded by it. These points are, in turn, fed to a Voronoi component (Mesh tab, Triangulation panel), which finds the largest nonoverlapping curves that surround each point and are still within the original rectangle. See Figure 5.2.
The final step is to use the Map to Surface component (Transform tab, Morph panel). This component requires three inputs: (C) The curves in the domain space to map to a target surface, (T) the target surface that the final curves end up on, and (S) a “source surface” representing the domain space. To create the source surface we feed the rectangle curve defined earlier to a Boundary Surfaces component (Surface tab, Freeform panel). This component creates a planar surface that is bounded by any closed planar curve, similar to Rhino’s built-in Planar Surface command. The final result is depicted in Figure 5.3.
FIGURE 5.2. Voronoi curves in the rectangular domain space of the cylinder.
In the previous section we used the Map to Surface component to put a curve on a surface. Here we show how to make other geometry conform to a surface. One common application is to emboss a logo on an object. Consider the logo created in Rhino, depicted in Figure 5.4.
The script depicted in Figure 5.5 will emboss this logo on a cylinder with the Surface Morph component (Transform tab, Morph panel). This useful component will take any user-defined geometry and deform it to follow a surface, similar to Rhino’s built-in Flow along Surface command.
FIGURE 5.3. The result of mapping the Voronoi curves of Figure 5.2 to a cylindrical surface with the Map to Surface component.
The Surface Morph component takes four essential pieces of data: (G) the geometry to transform, (R) a box containing that geometry, (S) the surface to transform the input geometry onto, and (U), (V), and (W), a box built by subsets of the surface’s u, v and w parameter space. (The w parameter represents a direction perpendicular to the surface.)
As in the example of the previous section, we will use a cylinder as the surface to transform the input geometry to. For the input geometry we use the logo depicted in Figure 5.4 by setting it to be referenced by the Brep component (Params tab, Geometry panel) in the script. We get a box containing the input geometry by feeding it to a Bounding Box component (Surface tab, Primitive panel).
FIGURE 5.4. A logo to be applied to a surface.
FIGURE 5.5. A script using the Surface Morph component to emboss a custom logo on a cylinder.
The U, V, and W inputs are created with Construct Domain components (Math tab, Domain panel), and each of those is determined by two number sliders. The values of the sliders that you see in the script were set to produce the result depicted in Figure 5.6
FIGURE 5.6. The result of morphing the logo depicted in Figure 5.4 onto a cylinder with the script of Figure 5.5.
A common modeling problem is to panel a surface with one or more sets of geometric components. While there are some very powerful plugins for paneling (e.g., Rajaa Issa’s Paneling Tools) with Grasshopper and Rhino, it is possible to use Grasshopper’s Surface Morph component to do basic paneling.