Ask Your Question
1

How to plot ellipsoid with interact?

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

updated 2019-03-02 12:56:43 -0500

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-02 21:24:40 -0500

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

2 followers

Stats

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

Seen: 53 times

Last updated: Mar 02