Ask Your Question

# How to plot ellipsoid with interact?

I would like to plot ellipsoid $\dfrac{x^2}{a^2}+\dfrac{y^2}{b^2}+\dfrac{z^2}{c^2}=1$ in SageMath, where the parameters $a,b,c$ can be changed interactively. I found it what I want here https://www.geogebra.org/m/cqtAE6Sm. But I want to do the same in Sage. How can I do it?

edit retag close merge delete

## 1 answer

Sort by ยป oldest newest most voted

The following code may serve as a starting point:

@interact
def ellipsoid(a=slider(1,5,step_size=0.2,default=3),
b=slider(1,5,step_size=0.2,default=3),
c=slider(1,5,step_size=0.2,default=2),
color=selector(["red","green","blue"],label="Color",default="green")):
x1, x2, y1, y2, z1, z2 = -a, a, -b, b, -c, c
var("x,y,z")
figure = implicit_plot3d(x^2/a^2+y^2/b^2+z^2/c^2==1, (x,x1,x2), (y,y1,y2), (z,z1,z2),
color=color, viewer='threejs')
show(figure)


It can be seen in action here. You may want to read this tutorial as well as these examples about the @interact command

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2019-03-02 11:24:11 -0500

Seen: 142 times

Last updated: Mar 02 '19