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.
FIGURE 4.4. The Perp Frames component has the same effect as a Divide Curve component, followed by a Perp Frame component.
FIGURE 4.5. The Domain2 component simultaneously extracts the u and v domains of a surface.
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.
FIGURE 4.6. The Evaluate Surface component is used to extract the location of a point on a surface, or a tangent plane to that surface, from u and v parameters.
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.
FIGURE 4.7. Dividing both the u and v domains is useful for finding a grid of points on a surface.
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.
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