Skip to content

kfahn22/polar_curves

Repository files navigation

Polar Curves

This repository contains a collection of p5.js sketches that utilize polar curves.

The base code is from Dan Shiffman's Heart Curve Coding Challenge.

Chrysanthemum Curve

I am using the equation for a chrysanthemum curve from Paul Bourke.

r = 5 (1 + sin(11 u / 5)) - 4 sin4(17 u / 3) sin8(2 cos(3 u) - 28 u) . . . where 0 <= u <= 21 pi

The center uses the code from Dan Shiffman's Phyllotaxis Coding challenge.

I am also using the P5.js patgrad libary to add a background gradient color to the flower.

Flower garden

In this sketch, I am using a Flower class to render multiple flowers and have adapted the "cannabis" curve to create the leaves. The formula for the cannabis curve is from Mathworld.

let r = this.lfsc * (1 + 7 / 10 * cos(4 * beta)) * (1 + 1 / 10 * cos(12 * beta)) * (5 / 10 + 0.06 * cos(40 * beta)) * (1 + sin(beta));
let x = r * cos(beta);
let y = -r * sin(beta);


p5 sketch
Code

Ophiuride Curve

I am using the equation from Wolfram Mathworld. I am graphing 120 curves with a random rotation with varying scale and alpha.

for (let theta = -170; theta < 170; theta += 1) {
let r = ( 0.2 * sin(theta) - 1.5 * cos(theta) ) * tan(theta);
let x = this.sc * r * cos(theta);
let y = -this.sc * r * sin(theta);}

p5 sketch

Spiral

I started with the equation for spherical spiral curve from spiral.

a = 0.9
b = 10 w = 50
const x = (rx * cos(w*theta)) / sqrt(a*a * theta*theta + b);
const y = (ry * sin(w*theta)) / sqrt(a*a * theta*theta + b);
const z = -(a * rz * theta ) / sqrt(a*a * theta*theta + b);
spiral

Other Resources

I ran across this reference, which has the equations for the Batman logo, the Twitter logo and even a "bunny" curve! Other Curves
Wolfram Mathworld

About

A collection of polar curves

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published