Hello! In our last lesson, we focused on bringing clarity and structure to your Grasshopper definitions. Now, as we begin our new module on generative modeling, you'll see how those organizational skills become essential for managing more complex and creative scripts.
This lesson bridges your strong foundation in mathematics with the practical world of parametric design. We will explore how to generate architectural curves not by drawing them manually, but by defining them with mathematical functions. You will learn to translate formulas and parametric equations directly into geometric form using Grasshopper's tools. By the end of this lesson, you will be able to plot functions like sine waves, create classic curves like the lemniscate, and apply these concepts to generate intricate 3D forms.
The Generative Workflow: From Function to Form
The fundamental process for generating a curve from a function in Grasshopper is a direct analogue to plotting a function by hand. It involves four key steps:
- Generate a Domain: Create a series of numbers that will serve as the input for your function. This is your independent variable, which we often call
t. TheRangecomponent is perfect for this. - Apply the Function: Feed the domain into a component that evaluates a mathematical function. This will produce a corresponding list of output values.
- Construct Points: Use the input and output values as coordinates to generate a list of points in space. For a simple 2D plot of
y = f(x), your input domain serves as the x-coordinates and the function's output as the y-coordinates. - Create a Curve: Connect the generated points with a curve component, such as
Interpolate CurveorNurbs Curve, to visualize the final form.
We will explore two primary methods for the "Apply the Function" step: the Expression component for explicit formulas and the Graph Mapper for visual function editing.
Method 1: Explicit Control with the Expression Component
The Expression component (Maths > Script > Expression) is a powerful tool that lets you type mathematical formulas directly into your definition. This method will feel very natural given your background, as it mirrors standard mathematical notation.
Example A: The Sine Wave
Let's start by generating a simple 2D sine curve, y = A * sin(t), where A is the amplitude and t is our parameter. The following video provides a clear walkthrough of this exact process.
Grasshopper 10 - Sine Functions
This video by Daniel Christev is an excellent introduction to using the Expression component to create and control a sine curve.
Please watch the following segments: Mathematical Background: A quick review of the sine curve and the relationship between degrees and radians (0 to 2π). Setting up the Components: See how to set up the Expression component for A*sin(T), create a Range for the T parameter (from 0 to 2π), and add a slider for the amplitude A. Constructing the Curve: Observe how the Range values (T) are used for the X-coordinates and the Expression outputs for the Y-coordinates to construct points, which are then interpolated into a curve. Parametric Control: This part demonstrates the power of parametricism. Notice how adjusting the sliders for amplitude (A) and the domain (the multiplier for π) dynamically changes the shape of the curve.
By following this workflow, you've turned a static mathematical equation into a dynamic, editable object. You can further enhance this by introducing parameters for frequency and phase shift inside the expression, as the video later demonstrates (A * sin(W*T + X)), giving you even more granular control.
Example B: The Lemniscate of Bernoulli
The Expression component is not limited to functions of the form y = f(x). It excels at creating curves from a set of parametric equations, like x = f(t) and y = g(t). A classic example is the Lemniscate, or infinity symbol.
The article below demonstrates how to generate this curve using its parametric form. It uses two separate Expression components, one for the X-coordinates and one for the Y-coordinates, both driven by the same t parameter.
Unlocking Creative Infinity: Lemniscate Design in Grasshopper
This article from HowToRhino provides a concise guide to generating a Lemniscate curve.
Read the section Bringing Lemniscate Theory to Life. Focus on how it sets up two variables, A (size) and t (domain, 0 to 2π), and plugs them into the parametric equations for X and Y using Expression components.
This example reinforces the concept of the curve parameter t as an abstract value that drives the geometry, rather than a direct spatial coordinate.
Method 2: Visual Functions with the Graph Mapper
While expressions are precise, sometimes a more intuitive, visual method of defining a function is preferable. The Graph Mapper component (Params > Input > Graph Mapper) serves this purpose. It maps a list of input values (typically in the domain [0, 1]) to a new list of output values based on the shape of an editable graph.
This is like sketching a function instead of writing its formula. The tutorial below walks through a simple project that uses this technique effectively.
Basic Grasshopper Tutorial — Blogs, Tutorials & Challenges | Fluxspace
This tutorial from Fluxspace demonstrates the core workflow of using a Graph Mapper to generate a form.
Please read through the first few steps of the tutorial: Start with the introduction about the core components: Range, Graph Mapper, and Point Cylindrical. Next, see how the Range component is set up in the section covering domain and steps. The key is to establish a domain, in this case from 0 to 1. Finally, read the sections that show how to connect the Range to the Graph Mapper and then wire the outputs to the Point Cylindrical component. Notice how the output of the Graph Mapper now drives the radius of the points. You can experiment by right-clicking the Graph Mapper and changing the "Graph type" to Sine, Perlin, or others to see how the "function" and thus the final geometry changes instantly.
Application in 3D: Generating Undulating Forms
We can now combine these techniques to create more complex 3D geometry. A common generative strategy is to take a simple base curve, like a circle or ellipse, and displace its points in the Z-direction using a mathematical function. This creates beautiful, undulating forms.

Here is a workflow to achieve a similar result:
- Create a base curve: Use a
CircleorEllipsecomponent. - Divide the curve: Use
Divide Curveto get a set of points and, importantly, their correspondingtparameters along the curve. - Generate Z-Offsets: Feed the
tparameters fromDivide Curveinto anExpressioncomponent that calculates a Z-offset. A sine function likeA * sin(F * t)is perfect for this.Acontrols the amplitude of the wave, andF(frequency) controls how many times the wave repeats around the circle. - Move the Points: Use
Deconstruct Pointon the division points. Feed the original X and Y values and your new Z-offsets into aConstruct Pointcomponent. - Create the Final Curve: Use an
Interpolate CurveorNurbs Curvecomponent on the newly constructed points to generate the final 3D form.
This same principle can be applied to a grid of points, where a function of their X and/or Y coordinates determines their Z-height, leading directly to the generation of parametric surfaces.

Conclusion
In this lesson, we translated abstract mathematical functions into tangible geometric curves. You now have two powerful methods for this generative process: the Expression component for precise, formula-driven design, and the Graph Mapper for intuitive, visual manipulation of form.
Key Takeaways:
- The core generative workflow involves creating a numerical domain (
Range), applying a function (ExpressionorGraph Mapper), constructing points, and interpolating a curve. - The
Expressioncomponent allows you to use standard mathematical notation to define relationships between parameters, making it ideal for implementing parametric equations. - Parameters like amplitude, frequency, and phase shift in a sine function become dynamic design controls in Grasshopper.
- The
Graph Mapperprovides a visual interface for defining functions, offering an intuitive alternative to writing explicit formulas. - These techniques can be extended into three dimensions to create complex, undulating curves and patterns.
Now that you can generate a wide variety of custom profile curves, our next lesson will focus on how to use these curves as the foundation for creating complex parametric surfaces using techniques like Loft, Sweep, and Revolve.