How to draw a spline: A ChatGPT case study

Changsin Lee
12 min readJun 25, 2023

Let’s use the task of drawing a spline in JS to see whether AI can beat humans

Photo by Luca Dugaro on Unsplash

· I. The Process
0. Setup: The data
1. The baseline
2. How to draw a single-line spline
3. How to draw a spline with varying widths?
4. Human intelligence to the rescue: A solution
5. ChatGPT was very good at converting code
6. Human intuition to the rescue: Draw 3 splines
7. Fill in the area: Another problem
8. The final solution
· II. The Analysis
· Conclusion
· Reference

The mathematical definition of a spline is “a special function defined piecewise by polynomials.” In computer science and computer graphics, it is a curved line based on interpolations. In layman’s terms, it is just a curved line.

Why do you need to draw a spline? Splines are of interest to AI researchers who want to train a model for autonomous driving because car lanes are basically splines.

My interests in drawing splines also stem from the need to process datasets for autonomous driving. I needed a way to display…

--

--

Changsin Lee

AI/ML Enthusiast | Software Engineer | ex-Microsoftie | ex-Amazonian