# enforce limits to x-axis in parametric_plot

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)]

b=animate(springs)

b.show(iterations=10)

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

Sort by » oldest newest most voted

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)


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 = [
(
parametric_plot3d(
[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)
]

more

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