Ask Your Question
1

How to plot ellipsoid with interact?

asked 2019-03-02 18:24:11 +0100

updated 2019-03-02 19:56:43 +0100

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-03-03 04:24:40 +0100

Juanjo gravatar image

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

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

3 followers

Stats

Asked: 2019-03-02 18:24:11 +0100

Seen: 482 times

Last updated: Mar 03 '19