Читать книгу Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman - Страница 12

Оглавление

5

Surface Transformations

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.

Mapping Curves to Surfaces

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.

Mapping Geometry to Surfaces

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.

Paneling with Surface Morph

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.

The script depicted in Figure 5.7 is a modification of that in Figure 5.5. For this example we will use the “panel” depicted in Figure 5.8. As before, this is referenced by the Brep component in the script.


FIGURE 5.7. A script to illustrate the Surface Morph component.

To get a paneling effect, we break up the domain of the surface into smaller regions with the Divide Domain2 component (Math tab, Domain panel). At the U and V inputs to this component we set numbers to tell it how many times to break up the domain in each direction. For the script depicted here, we have set the U input to the value 10, and the V input to the value 5. Thus, at the S output we get a list of 50 smaller rectangular domains. Each of these is then fed to a Deconstruct Domain2 component (Math tab, Domain panel) to find sets of U and V parameters. Finally, at the W input of the Surface Morph component we use a “0.0 to 1.0” Domain, output by default from a Construct Domain component (Math tab, Domain panel). After playing with the values set at the radius (R) and length (L) inputs of the Cylinder component, the result is the paneling of a cylinder depicted in Figure 5.9.


FIGURE 5.8. An object built with Rhino’s native tools to be used as a paneling component.


FIGURE 5.9. A cylinder paneled with 50 copies of the object depicted in Figure 5.8 with the Surface Morph component.

Grasshopper: Visual Scripting for Rhinoceros 3D

Подняться наверх