initial animation
This commit is contained in:
parent
4151d2489f
commit
2c44bae0da
1 changed files with 15 additions and 7 deletions
22
torus.py
22
torus.py
|
|
@ -1,6 +1,7 @@
|
|||
import numpy as np
|
||||
from numpy.polynomial.polynomial import Polynomial
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.animation as animation
|
||||
from matplotlib.widgets import Slider, Button
|
||||
|
||||
|
||||
|
|
@ -77,7 +78,7 @@ class TorusWorld:
|
|||
return np.allclose(self.surface_point(phi, theta), self.sun+roots[0]*ray)
|
||||
|
||||
def illumination(self, phi, theta):
|
||||
return np.dot(self.ray_vector(phi, theta), -self.normal_vector(phi, theta)) * self.is_illuminated(phi, theta)
|
||||
return np.dot(self.ray_vector(phi, theta), -self.normal_vector(phi, theta)) # * self.is_illuminated(phi, theta)
|
||||
|
||||
|
||||
class NoInamge():
|
||||
|
|
@ -100,7 +101,7 @@ class NoInamge():
|
|||
|
||||
self.ax.set_aspect('equal')
|
||||
self.ax.axis('off')
|
||||
|
||||
|
||||
self.init_top_view()
|
||||
self.init_side_view()
|
||||
self.init_map_view()
|
||||
|
|
@ -258,9 +259,7 @@ class NoInamge():
|
|||
return x, z+self._offset_side()
|
||||
|
||||
def redraw_plot(self, line, func):
|
||||
x, y = func()
|
||||
line.set_xdata(x)
|
||||
line.set_ydata(y)
|
||||
line.set_data(*func())
|
||||
self.ax.relim()
|
||||
self.ax.autoscale_view()
|
||||
|
||||
|
|
@ -357,11 +356,20 @@ class ImageInteractive(NoInamge):
|
|||
|
||||
class AnimatedImage(NoInamge):
|
||||
|
||||
def __init__(self, rfrac_init=0.5, sun_init=np.pi/2):
|
||||
def __init__(self, rfrac_init=0.5, sun_init=-np.pi):
|
||||
super().__init__(rfrac_init, sun_init)
|
||||
|
||||
self.ani = animation.FuncAnimation(self.fig, self.animate, frames=150)
|
||||
plt.show()
|
||||
|
||||
|
||||
def animate(self, frame_i):
|
||||
phi = (frame_i*2*np.pi/150)-np.pi
|
||||
self.update_sun(phi, 0)
|
||||
return self.lines.values()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# ImageStatic()
|
||||
ImageInteractive()
|
||||
# ImageInteractive()
|
||||
AnimatedImage()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue