Grasshopper Curve Frames-Arrays
In the Grasshopper Points from Curve tutorial you have learned to extract points from a curve by evaluating or dividing the curve. In this section, we elaborate on the different methods to distribute planes or geometries along a curve.
The first example demonstrates the difference between dividing a curve and connecting those points with a line versus creating perpendicular lines from the curves. This can be useful in creating stairs along a a curve, for example.
For the first example set one curve drawn in Rhino. Offset this curve using with a Number Slider for Distance. Divide both curves with the same number using and connect one Number Slider to both divide components with the same Number.
Using a component you can connect the two points. This is explained into more detail here: Grasshopper Points from Curve. Notice that the connecting lines are not perpendicular. This is because the equal divisions of the curve are not perpendicularly placed across each other.
If you want perpendicular lines to the curve, you use thecommand instead. Instead of returning a point, the Horizontal Frames returns a plane, oriented with a x-direction tangent to the curve and a y-direction perpendicular to the plane. Use a Number Slider or set a number to control the Number of Horizontal Frames. (Note: These are called Frames because they are planes derived from geometry)
To draw a line along the y-axis of the planes, use to extract the directions of the vector. Now use with the Starting point at the origin of the Frame and the y-direction of the deconstructed vector into the Direction. The Length of the line can vary, using a Number Slider.
If the direction of the offset and the SDL do not match, you can invert one or the other by using the tool. To complete the example, use an . The Distance should equal the length of the SDL line, by connecting the same Number Slider. If you want to retrieve the intersection points at the offset curve, use .
In addition to Horizontal Frames, Grasshopper also has a tool to distribute Perpendicular Frames with thecomponent. If you follow the same steps as above, you'll see that in this case the y-direction of the plane follows the z-direction of Rhino's world coordinate system and the x-direction is perpendicular to the curve.
You can also use the plane base primitive geometry on. For example, by defining it as an origin plane for a circle. Use the command and connect the Frame output to the Center point input of the CNR Circle. Also use the Frame for the Normal input of the CNR Circle. Every circle is now oriented perpendicular to the curve in the z-direction.
The difference between this method and the previous ones is that here we define a geometry to distribute along a curve rather than defining a point or plane to draw geometry upon or move geometry to. In this example we start with curve-geometry to be converted into a solid, but you can start with any type of geometry (point, curve, surface, brep) or even multiple geometries.
First, in Rhino, define your geometry to be arrayed along the curve. In this case, we have drawn a cross-like curve and set one curve. To convert this to a solid, we use and . For the extrusion, define the direction, in this case the z-direction by using . If we connect the capped Brep to the Geometry input of the command, it will distribute the geometry along the curve by a defined Number. This can be adjust by using a Number Slider or set a number.
Distance based Scaling using Remapping
Parametric design is about building relations between objects. In this example we will demonstrate one of this relations based on distance. We will show how an object is scaled based on the distance from the starting point of a line. Please keep in mind that a scale factor is always determined in percentages. If you want to scale an object in half, the scale factor is 0.5 (50%) if you want to double the size the scale factor is 2.0 (200%). This is important to understand when we use the remapping component. The concept of Remapping is quite similar to the Reparametrize option which was explained in more detail here: Grasshopper Points from Curve and later here: Grasshopper 3D Grid from Surface. Reparametrizing allows for redistributing a domain from 0-1, whereas the remapping component allows for redistributing a domain onto any new domain.
We continue to work on the same definition. First we need to set up the relationship. We want to measure the distance between the starting point of the original input curve and a point on the brep. For that, we explode the brep into its components; faces, edges and vertices. Use for this.
Then we retrieve one of the vertices (any will work, but closest to the curve give the least distortion) with . Let's flatten the data tree, since we have no need for it; right click on the Item output and select flatten.
We still have to define the starting point of the input curve. Use . Select the Starting Point and feed it into the A component. Feed the Item output from the List Item into the B input. If you pull up a panel if you want to see the calculated distances.
We now have to convert this set of distances into scale factors to perform the scalar operation. To understand the scalar operation, load the component. This component requires a Geometry input and allows you to scale in 3 directions, x,y and z. Use Number Sliders to control the scale factor. (0-1 for reducing or >1 for increasing in scale).
In order to convert the distances to a usable scale factor, we will Remap the domain of the distances onto a new domain from 0.25-1.00. This means that the closest object will be scaled by 0.25 and the furthest object will be scale by 1.00. If you switch the domain, from 1.00-0.25, the scalar operation will occur the other way around; the closest object will be scaled by 1.00 and the furthest object will be scaled by 0.25.
To Remap the distances, you need to find the bounds of the current domain with . Plug in the Distance output into the Numbers input of the Domain component. This will be the source domain.
For the target domain, we need to construct a new domain by using . Here we can define the start and end of the new domain with Number Sliders, for example 0.25 and 1.00. By exchanging the A and B input you control the scalar operation for the closest and furthest object.
Use the tool to remap the numbers by substituting the source domain for the target domain. The Values are the distances as a list. The Source domain comes from the Bounds component and the Target domain comes from the new Construct Domain component. The Remapped numbers now range from 0.25-1.00, where the lowest number is assigned 0.25 and the highest number is assigned 1.00. If you flip the A and B it will be the other way around.
Finally you can use the remapped numbers as a scale factor for the . If you want to decrease the height (by 0.25) of the object closest to the start of the curve, gradually increasing as you the geometry arrays along the curve, plug the Remapped Number into the Z input of the Scale NU component. Keeping the other scale factors (x&y) at 1, the geometry will be scaled into the z-direction only.
Distance based Scaling using Graphmapper
To control, for example, the height of the geometry according to a numeric mapping function, you could use thecommand. This component functions similarly to the Remapping tool, but the Graphmapper will redistribute the values dictated according to a defined graph.
You can select a Graph Type by right-clicking the Graph Mapper. If you select a Linear Graph, you get a similar result to what we had previously with the Remapping tool. If you select a Bezier Curve you can control the handles of a Curve (also known as a Bezier Curve). This gives you a lot of flexibility in playing with the height of your geometry.