1 | initial version |
I provide the full code: import ipywidgets as widgets from ipywidgets import FloatSlider, Button from IPython.display import display, clear_output from sage.all import var, sinh, cosh, sin, sqrt, cos, tan, pi, implicit_plot3d, show
x,y,z = var('x y z') t = 1# (x).function(x,y,z) cm = colormaps.gist_rainbow
u, v, z, a = var('u v z a') x, y, z = var('x y z') coordinates = (a * sinh(v) / (cosh(v) - cos(u)), a * sin(u) / (cosh(v) - cos(u)), z) show("Bispherical coordinates") show(coordinates)
EtaSlider = FloatSlider(value=0.6, min=0.1, max=1.5, step=0.1, description='u:', orientation='horizontal', continuous_update=False) ThetaSlider = FloatSlider(value=1.9, min=0.1, max=pi, step=0.1, description='v:', orientation='horizontal', continuous_update=False) PsiSlider = FloatSlider(value=6.1, min=0, max=2*pi-0.1, step=0.1, description='z:', orientation='horizontal', continuous_update=False) aSlider = FloatSlider(value=13.5, min=0.1, max=20, step=0.1, description='a:', orientation='horizontal', continuous_update=True)
display(EtaSlider) display(ThetaSlider) display(PsiSlider) display(aSlider)
button = Button(description='Plot') button.style.button_color = 'lightgreen' display(button)
reset = Button(description='Reset values') reset.style.button_color = 'lightgreen' display(reset)
def update_plot(change=None): eta = float(EtaSlider.value) theta = float(ThetaSlider.value) psi = float(PsiSlider.value) a = float(aSlider.value) clear_output(wait=True)
f_1 = x**2 + y**2 + z**2 - a * (sqrt(((x**2 + y**2) / sinh(eta)**2) + z**2 / cosh(eta)**2))
f_2 = x**2 + y**2 + z**2 - a * (sqrt((-(x**2 + y**2) / sin(theta)**2) + z**2 / cos(theta)**2))
f_3 = x * tan(psi) / y
p = implicit_plot3d(f_1, (x, -30, 30), (y, -20, 20), (z, -20, 20), color='lightblue', opacity=0.9, mesh=False, frame=False, smooth=True)
q = implicit_plot3d(f_2, (x, -20, 20), (y, -20, 20), (z, -20, 20), color='red', opacity=1, mesh=False, frame=False, smooth=True)
r = implicit_plot3d(f_3, (x, -20, 20), (y, -20, 20), (z, -20, 20), color='lightgreen', opacity=1, mesh=False, frame=False, smooth=True)
show("Inverse prolate spheroidal coordinates")
show(coordinates)
display(EtaSlider)
display(ThetaSlider)
display(PsiSlider)
display(aSlider)
display(button)
display(reset)
show("η:%s θ:%s ψ:%s a:%s" % (eta, theta, psi, a))
show(p + q + r)
def reset_values(sender): EtaSlider.value = 5.6 ThetaSlider.value = 1.9 PsiSlider.value = 6.1 aSlider.value = 13.5
EtaSlider.observe(update_plot, names='value') ThetaSlider.observe(update_plot, names='value') PsiSlider.observe(update_plot, names='value') aSlider.observe(update_plot, names='value') button.on_click(update_plot) reset.on_click(reset_values)
update_plot()
2 | No.2 Revision |
I provide the full code: import ipywidgets as widgets from ipywidgets import FloatSlider, Button from IPython.display import display, clear_output from sage.all import var, sinh, cosh, sin, sqrt, cos, tan, pi, implicit_plot3d, show
x,y,z = var('x y z') t = 1# (x).function(x,y,z) cm = colormaps.gist_rainbow
u, v, z, a = var('u v z a') x, y, z = var('x y z') coordinates = (a * sinh(v) / (cosh(v) - cos(u)), a * sin(u) / (cosh(v) - cos(u)), z) show("Bispherical coordinates") show(coordinates)
EtaSlider = FloatSlider(value=0.6, min=0.1, max=1.5, step=0.1, description='u:', orientation='horizontal', continuous_update=False) ThetaSlider = FloatSlider(value=1.9, min=0.1, max=pi, step=0.1, description='v:', orientation='horizontal', continuous_update=False) PsiSlider = FloatSlider(value=6.1, min=0, max=2*pi-0.1, step=0.1, description='z:', orientation='horizontal', continuous_update=False) aSlider = FloatSlider(value=13.5, min=0.1, max=20, step=0.1, description='a:', orientation='horizontal', continuous_update=True)
display(EtaSlider) display(ThetaSlider) display(PsiSlider) display(aSlider)
button = Button(description='Plot') button.style.button_color = 'lightgreen' display(button)
reset = Button(description='Reset values') reset.style.button_color = 'lightgreen' display(reset)
def update_plot(change=None): eta = float(EtaSlider.value) theta = float(ThetaSlider.value) psi = float(PsiSlider.value) a = float(aSlider.value) clear_output(wait=True)
f_1 = x**2 + y**2 + z**2 - a * (sqrt(((x**2 + y**2) / sinh(eta)**2) + z**2 / cosh(eta)**2))
f_2 = x**2 + y**2 + z**2 - a * (sqrt((-(x**2 + y**2) / sin(theta)**2) + z**2 / cos(theta)**2))
f_3 = x * tan(psi) / y
p = implicit_plot3d(f_1, (x, -30, 30), (y, -20, 20), (z, -20, 20), color='lightblue', opacity=0.9, mesh=False, frame=False, smooth=True)
q = implicit_plot3d(f_2, (x, -20, 20), (y, -20, 20), (z, -20, 20), color='red', opacity=1, mesh=False, frame=False, smooth=True)
r = implicit_plot3d(f_3, (x, -20, 20), (y, -20, 20), (z, -20, 20), color='lightgreen', opacity=1, mesh=False, frame=False, smooth=True)
show("Inverse prolate spheroidal coordinates")
show(coordinates)
display(EtaSlider)
display(ThetaSlider)
display(PsiSlider)
display(aSlider)
display(button)
display(reset)
show("η:%s θ:%s ψ:%s a:%s" % (eta, theta, psi, a))
show(p + q + r)
def reset_values(sender): EtaSlider.value = 5.6 ThetaSlider.value = 1.9 PsiSlider.value = 6.1 aSlider.value = 13.5
EtaSlider.observe(update_plot, names='value') ThetaSlider.observe(update_plot, names='value') PsiSlider.observe(update_plot, names='value') aSlider.observe(update_plot, names='value') button.on_click(update_plot) reset.on_click(reset_values)
update_plot()
update_plot()
3 | No.3 Revision |
I provide the full code:
code:
import ipywidgets as widgets
widgets
from ipywidgets import FloatSlider, Button
Button
from IPython.display import display, clear_output
clear_output
from sage.all import var, sinh, cosh, sin, sqrt, cos, tan, pi, implicit_plot3d, show
x,y,z = var('x y z')
t = 1# (x).function(x,y,z)
cm = colormaps.gist_rainbow
u, v, z, a = var('u v z a')
a')
x, y, z = var('x y z')
z')
coordinates = (a * sinh(v) / (cosh(v) - cos(u)), a * sin(u) / (cosh(v) - cos(u)), z)
z)
show("Bispherical coordinates")
coordinates")
show(coordinates)
EtaSlider = FloatSlider(value=0.6, min=0.1, max=1.5, step=0.1, description='u:', orientation='horizontal', continuous_update=False)
continuous_update=False)
ThetaSlider = FloatSlider(value=1.9, min=0.1, max=pi, step=0.1, description='v:', orientation='horizontal', continuous_update=False)
continuous_update=False)
PsiSlider = FloatSlider(value=6.1, min=0, max=2*pi-0.1, step=0.1, description='z:', orientation='horizontal', continuous_update=False)
continuous_update=False)
aSlider = FloatSlider(value=13.5, min=0.1, max=20, step=0.1, description='a:', orientation='horizontal', continuous_update=True)
display(EtaSlider)
display(ThetaSlider)
display(PsiSlider)
display(EtaSlider)
display(ThetaSlider)
display(PsiSlider)
display(aSlider)
button = Button(description='Plot')
Button(description='Plot')
button.style.button_color = 'lightgreen'
'lightgreen'
display(button)
reset = Button(description='Reset values')
values')
reset.style.button_color = 'lightgreen'
'lightgreen'
display(reset)
def update_plot(change=None):
eta = float(EtaSlider.value)
theta = float(ThetaSlider.value)
psi = float(PsiSlider.value)
a = float(aSlider.value)
clear_output(wait=True)update_plot(change=None):
eta = float(EtaSlider.value)
theta = float(ThetaSlider.value)
psi = float(PsiSlider.value)
a = float(aSlider.value)
clear_output(wait=True)
f_1 = x**2 + y**2 + z**2 - a * (sqrt(((x**2 + y**2) / sinh(eta)**2) + z**2 / cosh(eta)**2))
f_2 = x**2 + y**2 + z**2 - a * (sqrt((-(x**2 + y**2) / sin(theta)**2) + z**2 / cos(theta)**2))
f_3 = x * tan(psi) / y
p = implicit_plot3d(f_1, (x, -30, 30), (y, -20, 20), (z, -20, 20), color='lightblue', opacity=0.9, mesh=False, mesh=False,
frame=False, smooth=True)
smooth=True)
q = implicit_plot3d(f_2, (x, -20, 20), (y, -20, 20), (z, -20, 20), color='red', opacity=1, mesh=False, frame=False, smooth=True)
frame=False,
smooth=True)
r = implicit_plot3d(f_3, (x, -20, 20), (y, -20, 20), (z, -20, 20), color='lightgreen', opacity=1, mesh=False, frame=False, smooth=True)
frame=False,
smooth=True)
show("Inverse prolate spheroidal coordinates")
show(coordinates)
display(EtaSlider)
display(ThetaSlider)
display(PsiSlider)
display(aSlider)
display(button)
display(reset)
show("η:%s θ:%s ψ:%s a:%s" % (eta, theta, psi, a))
show(p + q + r)
def reset_values(sender):
reset_values(sender):
EtaSlider.value = 5.6
ThetaSlider.value = 1.9
PsiSlider.value = 6.1
aSlider.value = 13.513.5
EtaSlider.observe(update_plot, names='value')
names='value')
ThetaSlider.observe(update_plot, names='value')
names='value')
PsiSlider.observe(update_plot, names='value')
names='value')
aSlider.observe(update_plot, names='value')
button.on_click(update_plot)
names='value')
button.on_click(update_plot)
reset.on_click(reset_values)
update_plot()
three functions. All colors then will be blue
4 | No.4 Revision |
I provide the full code:
import ipywidgets as show(coordinates)
display(EtaSlider)
display(ThetaSlider)
display(PsiSlider)
display(aSlider)
display(button)
display(reset)
smooth=True)
smooth=True)
def reset_values(sender):
EtaSlider.value = 5.6
ThetaSlider.value = 1.9
PsiSlider.value = 6.1
aSlider.value = 13.5
EtaSlider.observe(update_plot, names='value')
ThetaSlider.observe(update_plot, names='value')
PsiSlider.observe(update_plot, names='value')
aSlider.observe(update_plot, names='value')
button.on_click(update_plot)
reset.on_click(reset_values)
update_plot()
the three functions. All colors then will be blue