Grasshopper: Visual Scripting for Rhinoceros 3D. David Bachman

Grasshopper: Visual Scripting for Rhinoceros 3D - David Bachman


Скачать книгу
the script of Figure 4.3 with a Perp Frame component (Curve tab, Analysis panel). However, Grasshopper also includes a Perp Frames component (Curve tab, Division panel) that does the same thing. See Figure 4.4.

      As in the case with curves, it is often necessary to work with surface parameters. These are always two numbers, u and v, each within a particular domain. You can view the u and v domains of a surface simultaneously by feeding it to a Domain2 component (Params tab, Primitive panel), as in Figure 4.5.

      To specify a point on a surface, one needs to give the values of u and v that correspond to it to an Evaluate Surface component (Surface tab, Analysis panel). This can be done by connecting any component that outputs the coordinate of a point, with the desired values of the surface parameters u and v being its x and y coordinates. In Figure 4.6, for example, these u and v values are specified by sliders, and the resulting plane at the F output of the Evaluate Surface component is used to locate a circle that is tangent to the cone.

img img

      Just as we did for curves, it is often necessary to simultaneously locate multiple points on a surface. One way to do this is to first connect the surface to a Deconstruct Domain2 component (Math tab, Domain panel) to separate the u and v domains. These can, in turn, be given to a Range component to extract some number of values in each domain. Finally, both lists of values can be given to a Construct Point component, with one grafted, to specify a grid of points on the surface. In the script depicted in Figure 4.7, tangent planes at the resulting points on the surface are then used to locate a collection of cones.

img

      When designing an object it is often necessary to offset it in a particular direction. This is useful, for example, when preparing a surface for 3D printing, since the slicing software used to prepare objects to be printed often requires the model be a solid object bounding a volume. In Figure 4.8 we see the result of feeding a paraboloid, created with native Rhino tools, into a Grasshopper Offset Surface component (Surface tab, Utilities panel). Notice that the Grasshopper-generated surface depicted in the figure is a constant distance away from the original paraboloid. To create a more interesting surface, one can offset the surface instead by an amount proportional to some function of the u and v parameters.

img

      Consider the script in Figure 4.9. As before, the domain of the surface is first decomposed into individual u and v domains with a Deconstruct Domain2 component, and then a grid of points in the surface parameter space is created with two grafted Range components. The P output of the Evaluate Surface component gives the location of a corresponding point on the paraboloid, and the N output gives a unit normal (perpendicular) vector there. These normal vectors are then scaled by the square of the sine of the v parameter, and added back to the location of the points on the surface to find the location of a grid of points that are offset from the surface by a varying amount. Finally, this offset grid is fed to a Surface from Points component to create a new surface, depicted at the bottom of the figure.

img img

       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.

      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.

img

      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


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