designcoding
About Table of Contents Keywords Monthly Archive
Support designcoding!

Fourier Series

November 14, 2022 | Algorithms
#fourier #grasshopper #rhino-python

This is my first experiment with the Fourier Series in Grasshopper using Python. This is a technique to decompose functions into their frequency components. Fourier series have a wide range of applications in physics and engineering. What makes it especially fascinating, however, is the visual intuition it offers. It looks like a kind of mathematical “magic” that emerges from the geometry of frequency. I explored several excellent visual explanations online, including those by Coding Train, 3Blue1Brown, and Mathologer, each offering a unique perspective.

Fourier Series animation

This Grasshopper definition includes a Python component that animates a set of rotating circles and the resulting wave. It serves as an introduction to more complex explorations. The N input controls the number of circles (harmonics), allowing you to observe how increasing complexity affects the wave. The t input advances the rotation, enabling animation. This is an early-stage experiment. I aimed at understanding the fundamentals of the technique. The more intriguing direction would be to reverse the process: given a waveform, the circle parameters that reconstruct it would be determined. This can be the core purpose of the Discrete Fourier Transform. I studied that topic here.

Fourier Series Grasshopper definition
import rhinoscriptsyntax as rs
import math
a, b, c, wave_pts = [], [], [], []
dt, t = math.pi / 200, -2 * t * math.pi
x, y = P[0], P[1]
for i in range(N):
    n = i * 2 + 1
    r = 4 / (n * math.pi)
    prev = [x, y, 0]
    x += r * math.cos(n * t)
    y += r * math.sin(n * t)
    a += [rs.AddCircle(prev, r), rs.AddCircle([x, y, 0], 0.02)]
    b.append(rs.AddLine([x, y, 0], prev))
tw = 2 * math.pi
while tw > 0:
    wy = P[1] + sum(4 / ((i * 2 + 1) * math.pi) * math.sin((i * 2 + 1) * (t + tw)) for i in range(N))
    wave_pts.append([3.6 + tw / 2, wy, 0])
    tw -= dt
c.append(rs.AddInterpCurve(wave_pts))
b.append(rs.AddLine([x, y, 0], [3.6, y, 0]))

Above is the Fourier Series code I wrote in the Python component. So, it should work in Rhino 6, 7, and 8 without problems. However, you can rebuild the component by copying the code above.

Fourier Series fourier, grasshopper
Grasshopper definition (GH)Download
Grasshopper definition (GH)Download

Cite this post

Yazar, T. (2022, November 14). Fourier Series. designcoding. Retrieved September 13, 2026, from https://www.designcoding.net/fourier-series/

Related Posts

Discrete Fourier Transform

May 8, 2025

The Fourier Transform is a powerful mathematical technique that allows us to analyze the different frequency components within a signal or shape. Its discrete version, the Discrete Fourier Transform (DFT), is used when working with numerical data. I studied the Fourier Series here before. One of the most fascinating aspects of the DFT is that it can represent a signal or shape using rotating circles (or vectors). Each circle corresponds to a specific frequency, amplitude, and phase. When connected in…

Flow Map on Terrains

September 11, 2026

We previously looked at the terrain generator script we used in projects with first-year architecture students over here. Later on, we added a few analysis modules to this tool. You might remember the slope analysis tool from this link. Today’s topic is another type of analysis: flow. The idea for this code wasn’t actually mine; I developed it by looking at an existing script based on Serkan Uysal’s suggestion. Unfortunately, I don’t know who originally wrote it. Keeping track of…

Dual Polyhedra in Grasshopper

October 7, 2025

Exploring dual polyhedra in Grasshopper is an interesting topic. In this post, I try to generate the dual of any polyhedron using Rhino Python and possibly Grasshopper. I developed this code for Rhino Python earlier here, and now I have converted it into a Grasshopper-Python component for better usability. I start the process by breaking the polyhedron into individual faces and gathering the corner points of each face. These points become the vertices of the dual polyhedron. Then, for each…

String Art in Rhino Python

June 19, 2025

String art is a cool art technique that combines geometry and aesthetics to recreate images using lines between pins. Here is a good reference to start studying it. In this post, I explored a custom Rhino Python script designed for Rhinoceros 7 and 8. It transforms a grayscale image into a dense web of threads. The algorithm analyzes the darkest areas of the image and connects pins in a circular layout to form compositions. The script begins by converting a…

Differential Growth

June 16, 2025

Differential growth is a process where different parts of a structure grow at different rates, leading to complex forms. After watching this, I decided to try it in Grasshopper. Here, differential growth mimics this behavior by applying rules such as Repulsion to avoid crowding or overlapping, Cohesion to keep parts connected or within a range, and Insertion to add new elements when a part stretches too far. The algorithm I present here simulates a differential growth process starting from a…

  • Chapters

    • Algorithms
    • Discourses
    • Fabrications
    • Studios
  • Explore

    • All Keywords
    • Table of Contents
    • Monthly Archive
    • #polyhedra
    • #robot
    • #parametric-surface
    • #terrain
    • #boolean
    • #kuka-prc
    • #parametric-curve
    • #tessellation
    • #design-object
    • #image-sampler
    • #simulation
    • #vector-field
    • #growth
    • #linear-algebra
    • #sandblasting
    • #stone
    • #dome
    • #animation
    • #art
    • #eps-foam
  • Search

  • Support designcoding!

  • Enjoying designcoding? Support me on Patreon to keep it growing. Thank you!

  • copyright 2026 designcoding.net | about | privacy policy | end user license agreement