So far, limiting the z range in 3D plots from plot3d,
parametric_plot or parametric_plot3d is missing.
Providing this feature is tracked at
- Sage Trac ticket 31264
Allow setting zmin, zmax in plot3d and other 3d plots
Using implicit_plot3d can be a workaround,
given an equation for the surface ...which is easy
in the case of plot3d but usually not in the case
of parametric_plot3d.
To limit the x, y and z ranges in a parametric plot,
we can alternatively use auxiliary functions which
return their computed value when it is within bounds,
and return "not a number" otherwise.
Here is a way to do that for the plot in the question.
We use cached functions to save computation time.
```
z = SR.var('z')
E = EllipticCurve(QQ, [0, 0, 0, -1/4, 0])
nan = float('nan')
@cached_function
def wpuv(u, v):
return wp(u + i*v)
@cached_function
def xuv(u, v):
return wpuv(u, v).real()
@cached_function
def yuv(u, v):
return wpuv(u, v).imag()
@cached_function
def zuv(u, v):
return wpp(u + i*v).imag()
xmin, xmax = -1, 1
ymin, ymax = -1, 1
zmin, zmax = -1, 1
@cached_function
def xok(u, v):
return xmin < xuv(u, v) < xmax
@cached_function
def yok(u, v):
return ymin < yuv(u, v) < ymax
@cached_function
def zok(u, v):
return zmin < zuv(u, v) < zmax
@cached_function
def xyzok(u, v):
return xok(u, v) and yok(u, v) and zok(u, v)
@cached_function
def xxuv(u, v):
return xuv(u, v) if xyzok(u, v) else nan
@cached_function
def yyuv(u, v):
return yuv(u, v) if xyzok(u, v) else nan
@cached_function
def zzuv(u, v):
return zuv(u, v) if xyzok(u, v) else nan
uu = (1e-3, 3.74)
vv = (1e-3, 3.74)
pp = parametric_plot3d
pp([xxuv, yyuv, zzuv], uu, vv)
```
That's already an interesting view.
To refine it, check which values of (u, v) give (x, y, z) within bounds:
```
good_uv_x = region_plot(xok, uu, vv)
good_uv_y = region_plot(yok, uu, vv)
good_uv_z = region_plot(zok, uu, vv)
good_uv_xyz = region_plot(xyzok, uu, vv)
good_uv = [good_uv_x, good_uv_y, good_uv_z, good_uv_xyz]
graphics_array(good_uv, ncols=2)
```
This reveals that values of u and v beyond 3.2 are not so useful.
Use a reduced range for u and v, and increase the number of plot points:
```
uu = (RDF(1e-3), RDF(3.2))
vv = (RDF(1e-3), RDF(3.2))
pp([xxuv, yyuv, zzuv], uu, vv, plot_points=129)
```