Grasshopper Curve Frames-Arrays

From TOI-Pedia

Introduction

LEVEL: BEGINNER

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.

Horizontal Frames

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.

Divide Curve, not perpendicular to curve


For the first example set one curve drawn in Rhino. Offset this curve using Curve » Util » Offset with a Number Slider for Distance. Divide both curves with the same number using Curve » Division » Divide and connect one Number Slider to both divide components with the same Number.


Using a Curve » Primitive » Line 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.




Horizontal Frames, perpendicular to curve

If you want perpendicular lines to the curve, you use the Curve » Division » Horizontal Frames command 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 Vector » Plane » Deconstruct Plane to extract the directions of the vector. Now use Curve » Primitive » Line SDL 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 Math » Operators » Negative tool. To complete the example, use an Curve » Util » Offset. 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 Intersect » Physical » Curve-Curve.

Perpendicular Frames

Perpendicular Frames, perpendicular to curve in z-direction

In addition to Horizontal Frames, Grasshopper also has a tool to distribute Perpendicular Frames with the Curve » Division » Perp Frames component. 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 Curve » Primitive » Circle CNR 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.

Curve Array

Curve Array, an object moved along a curve

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 Surface » Freeform » Extrude and Surface » Util » Cap Holes. For the extrusion, define the direction, in this case the z-direction by using Vector » Vector » Unit Z. If we connect the capped Brep to the Geometry input of the Transformations » Array » Curve Array 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

LEVEL: INTERMEDIATE
Distance based remapping,scaled according to distance from starting point
Scale in x,y,z directions
Remapping numbers from a source domain to a target domain

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 Surface » Analysis » Deconstructfor this.


Then we retrieve one of the vertices (any will work, but closest to the curve give the least distortion) with Sets » List » List Item. 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 Curve » Analysis » End Points. Select the Starting Point and feed it into the A Vector » Point » Distance 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 Transformations » Affine » Scale NU 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 Math » Domain » Bounds. 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 Math » Domain » Construct Domain. 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 Math » Domain » Remap 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 Transformations » Affine » Scale NU. 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

Remapping numbers using the Graphmapper
Graphmapper Sinc-graph

To control, for example, the height of the geometry according to a numeric mapping function, you could use the Params » Input » Graphmapper command. This component functions similarly to the Remapping tool, but the Graphmapper will redistribute the values dictated according to a defined graph.



















How to select different Graph Types with Graphmapper
Graphmapper Bezier-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.

Personal tools
Actions
Navigation
Tools