Python library for analyzing, exploring, and visualizing epitrochoids and hypotrochoids in just a few lines of code
spyrograph: elegant mathematics and geometries
What is it?
spyrograph is a lightweight Python package that provides an expressive and flexible set of tools for drawing beautiful mathematically driven art. With just a few lines of easy-to-read code you can start analyzing, visualizing, and exploring elegant mathematics
To begin, we'll need to install the spyrograph package. You can do this by running the following command:
pip3 install spyrograph
Once you have the package installed, let's import the Hypotrochoid class to trace our shape:
fromspyrographimportHypotrochoid
Using the trace method
The trace method is one of the centerpieces of the spyrograph package, allowing users to draw beautiful hypotrochoids and epitrochoids with ease
And to top it off the method comes with a variety of customization options, enabling users to create unique patterns suited to their usecase
Here's a simple example to get us started:
importnumpyasnp# Instantiate our hypotrochoid
thetas=np.arange(0,2*np.pi,0.05)hypotrochoid=Hypotrochoid(R=200,r=50,d=50,thetas=thetas)# Draw the hypotrochoid using the trace method
hypotrochoid.trace(exit_on_click=True)
This code snippet will create a hypotrochoid with the specified parameters and trace it on the turtle screen
You can experiment with different values for R, r, d, and thetas to create a wide variety of patterns and shapes
Customizing the visualization
The trace method offers a wide range of customization options to suit our usecase as needed
Here's an example of how to modify various aspects of the visualization: