Created
June 1, 2021 22:40
-
-
Save spite/77d2c59d73d3e022574fe7291f45dd54 to your computer and use it in GitHub Desktop.
superellipse / squircle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// superellipse / Lamé curve | |
// https://en.wikipedia.org/wiki/Superellipse | |
const a = 0.4; // semi-diameter | |
const b = 0.4; // semi-diameter | |
const n = 1.5; // curve (<1, 1-2, >2) | |
const c = Math.cos(gamma); // gamma 0-2π | |
const s = Math.sin(gamma); // gamma 0-2π | |
const x = Math.pow(Math.abs(c), 2 / n) * a * Math.sign(c); | |
const y = Math.pow(Math.abs(s), 2 / n) * b * Math.sign(s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment