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

Оглавление

4

Curves and Surfaces

Curve Parameters

Grasshopper has a lot of specialty components for working with curves. Many of these require that you understand curve parameters. A curve parameter is a number that corresponds to a specific place along a curve. The set of all numbers that correspond to curve points is called the domain of the curve. You can easily see the domain of a given curve by hooking it up to a Domain component (Params tab, Primitive panel), as in Figure 4.1.


FIGURE 4.1. The Domain component extracts the domain of a curve, which is displayed here with a Panel component.

Once you have determined a curve parameter (i.e. a point in its domain), you can use it with several other Grasshopper components. Consider, for example, the script depicted in Figure 4.2. Here we have fed the output of a Curve component to the D input (Domain) of a Range component to pick out 10 different curve parameters. These are then, in turn, given to a Curve Frame component (Curve tab, Analysis panel) to define a series of planes that are tangent to the given curve at 10 different places. Finally, we use a Circle component to define 10 circles in these planes.


FIGURE 4.2. The Range component picks out values in the domain of a curve that is attached to its D input. These values give curve parameters that are used to define circles in planes tangent to the curve.

Notice the circles in Figure 4.2 are not equally spaced along the curve, even though the Range component defined 10 equally spaced values of the curve parameter. This is because the transformation from curve parameter domain to a three-dimensional curve is not uniform speed. Where this transformation is faster, the circles are farther apart. If evenly spaced circles are more desirable, one can choose curve parameters with the Divide Curve component (Curve tab, Division panel) instead of the Range component, as in Figure 4.3.


FIGURE 4.3. The Divide Curve component will give curve parameters that are equally spaced along the curve.

Grasshopper includes many shortcuts that circumvent the direct interaction with curve parameters. For example, if you want to make circles perpendicular to a curve, rather than tangent, you can replace the Curve Frame component in 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.

Surface Parameters

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.

Variable Offset Surfaces

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: Visual Scripting for Rhinoceros 3D

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