Ask Your Question

enforce limits to x-axis in parametric_plot

asked 2022-04-10 23:44:13 +0200

r-johns gravatar image

I am trying to animate a classical harmonic oscillator (mass hooked to a spring attached to a wall). I have tried many variations of the following code to try to make the limits on the x-axis static: ...

springs=[parametric_plot3d([x,yy(x,t),zz(x,t)],(x,0,D(t)), xmin=0,xmax=11,plot_points=400,thickness=2) for t in sxrange (0,2,.2)]


The result is what appears to be a fixed spring with the coordinates of the x-axis changing rapidly. How can I use something similar to xmin and xmax in parametric_plot3d?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-04-11 00:57:17 +0200

Dan-K gravatar image

From the documentation it looks like sage.plot.animate.animate has parameters xmin, xmax, ymin, ymax:

b = animate(springs, xmin = 0, xmax = 11, ymin = targetYMin, ymax = targetYMax)

Doubled checked the source code and there are no z min/max parameters.

If this doesn't work for you and you need to stabilise the z direction as well, you should use boundary geometry such that this geometry lies at the minimum and maximum bounds of the x, y, and z axes.

Here I'm adding a sage.plot.plot3d.shapes.Box with opacity 0.1 but it might work with opacity 0:

xRange = 11 - 0
yRange = targetYMax - targetYMin
zRange = targetZMax - targetZMin

springs = [
            [x, yy(x,t), zz(x,t)],
            (x, 0, D(t)),
            plot_points = 400,
            thickness = 2
        + Box([xRange, yRange, zRange], opacity = 0.1).translate(xRange/2, yRange/2, zRange/2)
    ) for t in sxrange(0, 2, 0.2)
edit flag offensive delete link more


3D plots have an add_condition method ; could you see if you can pass it to animate ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-04-11 10:05:37 +0200 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2022-04-10 23:44:13 +0200

Seen: 149 times

Last updated: Apr 11 '22