designcoding
About Table of Contents Keywords Monthly Archive
Support designcoding!

Quick Parametric Curves

July 28, 2024 | Algorithms
#parametric-curve #rhino-python #tutorial

Here is the shortest possible way of generating quick parametric curves in Rhino Python. So, you may change the f, g, and h functions to test any function curve. In this Python code, the list comprehension [(f(t), g(t), h(t)) for t in [t0 + i*dt for i in range(int((t1-t0)/dt)+1)]] works by first generating a list of t values from t0 to t1 with an increment of dt using the inner comprehension. The outer comprehension then iterates over these t values, computing the x, y, and z coordinates for each point using the functions f(t), g(t), and h(t), respectively. Finally, this results in a list of 3D points I used rs.AddPolyline to create a polyline in Rhino. In Python, a lambda function is a small anonymous function with one expression. This means, it is evaluated and returned when the function is called.

Below Rhino Python script generates a 2D parametric curve in Rhino based on user-defined functions f and g. They define the x and y coordinates of points along the curve. The graph function iterates over a range of t values from t0 to t1 with a step of dt, calculates the coordinates using f and g, and adds the polyline to Rhino.

import rhinoscriptsyntax as rs, math
def graph(f, g, t0, t1, dt):
	rs.AddPolyline([(f(t), g(t), 0) for t in [t0 + i*dt for i in range(int((t1-t0)/dt)+1)]])
f = lambda t: t * math.sin(t)
g = lambda t: t * math.cos(t)
graph(f, g, -1, 12, 0.01)
Quick Parametric Curves parametric-curve, rhino-python
Python file (PY)Download
Python file (PY)Download

Cite this post

Yazar, T. (2024, July 28). Quick Parametric Curves. designcoding. Retrieved August 24, 2026, from https://www.designcoding.net/quick-parametric-curves/

Related Posts

B-Spline Construction

January 25, 2024

I have been studying the Bezier-De Casteljau algorithm for several years. Last week, I finally managed to understand and implement B-Spline Construction in Rhino and Grasshopper Python code, using the Cox-De Boor algorithm. This algorithm calculates the effect of control points on a B-Spline with many control points. After this, I am not limited to the degree+1 control points. This animation shows both algorithms working together. This Rhino Python code in a Grasshopper definition can handle three tasks. The first…

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…

Curve Equations Revisited

October 14, 2021

This is the continuation of the previous post on parametric curve equations. In this new version, the script picks a NURBS curve from the user. Then, it analyses the curve’s degree and control points. Unfortunately, only the curves with degree+1 number of control points can be processed. In the future, I hope that I will be able to extend this script to include multi-span curves with more than degree +1 control points. Finally, the script creates the three functions for…

Parametric Curve Equations

September 19, 2021

The parametric curve equations are good examples to demonstrate the bridge between computer-aided design and mathematics. Although useless and pointless, it is a good exercise to extract the curve equations. In this Rhino Python code, I present a generalized equation extractor for Rhino. Rhino curves are good examples de Casteljau and Bézier curves. You can see the mathematical underpinnings of Rhino curves with this exercise: This code asks the user the degree of the curve. By default, Rhino’s curves are…

Derivative and Slope

April 6, 2018

Yes, interesting topics started to reveal themselves, when I dig into the function curves, especially in the parametric representation. The first interesting application is the “derivative”. Nobody in high school told me that the derivative of a function at a given point gives the slope of the graph at that point. Moreover, it is possible to convert the slope value into an angle in degrees, showing the angle of the tangent line to the x-axis at that point. They are…

  • Chapters

    • Algorithms
    • Discourses
    • Fabrications
    • Studios
  • Explore

    • All Keywords
    • Table of Contents
    • Monthly Archive
    • #rhinoceros
    • #polyhedra
    • #unrolling
    • #archimedean-solid
    • #grasshopper
    • #platonic-solid
    • #parametric-surface
    • #folding
    • #truncated
    • #relief
    • #icosahedron
    • #buckminster-fuller
    • #dual
    • #icosidodecahedron
    • #dodecahedron
    • #stellated-solid
    • #cuboctahedron
    • #octahedron
    • #catenary
    • #dome
  • 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