Last active
July 14, 2021 10:41
-
-
Save goingtosleep/f36a515bb53ea7e532a71e64f511b9ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from numpy import pi, sin, cos, exp, linspace, meshgrid | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
def mod(x, y): | |
return x % y | |
def surf(X, Y, Z): | |
ax = plt.axes(projection='3d') | |
ax.plot_surface(X, Y, Z, cmap=cm.coolwarm) | |
plt.tight_layout() | |
n = 800 | |
A = 1.995653 | |
B = 1.27689 | |
C = 8 | |
petalNum = 3.6 | |
r = linspace(0,1,n) | |
theta = linspace(-2,20*pi,n) | |
[R,THETA] = meshgrid(r, theta, indexing='ij') | |
x = 1 - (1/2)*((5/4)*(1 - mod(petalNum*THETA, 2*pi)/pi)**2 - 1/4)**2 | |
phi = (pi/2)*exp(-THETA/(C*pi)) | |
y = A*(R**2)*(B*R - 1)**2*sin(phi) | |
R2 = x*(R*sin(phi) + y*cos(phi)) | |
X = R2*sin(THETA) | |
Y = R2*cos(THETA) | |
Z = x*(R*cos(phi) - y*sin(phi)) | |
surf(X, Y, Z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment