Skip to content

Instantly share code, notes, and snippets.

@Aidgigi
Last active October 17, 2021 21:52
Show Gist options
  • Save Aidgigi/69b5bad697a6e566ce1b76078bea350a to your computer and use it in GitHub Desktop.
Save Aidgigi/69b5bad697a6e566ce1b76078bea350a to your computer and use it in GitHub Desktop.
test
from math import *
from matplotlib.pyplot import *
from ion import *
def f(x,y): return x**2+y**2
rot=1
tilt=1
def draw(rot, tilt):
a=-2
b=2
c=-2
d=2
m=8
n=8
M1=-sin(rot)
M2=cos(rot)
M4=-cos(rot)*cos(tilt)
M5=-sin(rot)*cos(tilt)
M6=sin(tilt)
dx=(b-a)/m
dy=(d-c)/n
for s in range(n+1):
X=[(a+dx*t) for t in range(m+1)]
Y=[(c+dy*s) for t in range(m+1)]
Z=[f(X[t],Y[t]) for t in range(m+1)]
xP1=[(M1*X[i]+M2*Y[i]) for i in range(m+1)]
yP1=[(M4*X[i]+M5*Y[i]+M6*Z[i]) for i in range(m+1)]
plot(xP1,yP1)
for t in range(m+1):
X=[(a+dx*t) for s in range(n+1)]
Y=[(c+dy*s) for s in range(n+1)]
Z=[f(X[s],Y[s]) for s in range(n+1)]
xP2=[(M1*X[i]+M2*Y[i]) for i in range(n+1)]
yP2=[(M4*X[i]+M5*Y[i]+M6*Z[i]) for i in range(n+1)]
plot(xP2,yP2)
show()
draw(rot, tilt)
"""
while True:
draw(rot, tilt)"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment