Although @slelievre has solve the question, I would like to provide some additional solutions in terms of the plot3d
function which may be helpful.
First solution
This is essentially a rewrite of @slelievre code by replacing parametric_plot3d
by plot3d
:
var("z,t,θ")
r = t*(1-cos(θ))
Cyl = (r*cos(θ),r*sin(θ),z)
plot3d(r^2*cos(θ)^2, (t,0,1), (θ,0,2*pi), transformation=Cyl,
plot_points=[10,120])
Please note that, in cylindrical coordinates, the surface is z=r2cos(θ)2.
Second solution
You can plot a function whose value is NaN
outside the domain. The corresponding points will not appear in the graphic:
var("z,r,θ")
Cyl = (r*cos(θ),r*sin(θ),z)
def fun(r,θ):
if r<=1-cos(θ):
return r^2*cos(θ)^2
else:
return NaN
plot3d(fun, (r,0,2), (θ,0,2*pi), transformation=Cyl,
plot_points=[100, 300])
The problem of this approach is that the surface boundary appears too much jagged.
Third solution
You can plot the surface in a bigger domain and then remove the unwanted part:
var("x,y,z")
fig = plot3d(x^2, (x,-2,2), (y,-2,2))
cond = lambda x,y,z: sqrt(x^2+y^2) <= 1-cos(arctan2(y,x))
fig = fig.add_condition(cond)
show(fig)
In cartesian coordinates, the surface is z=x2. One has to keep only those points (x,y,z) whose cylindrical coordinates (r,θ,z) satisfy the condition r≤1−cos(θ), which can be expressed in cartesian coordinates as
√x2+y2≤1−cos(arctan2(y,x)).
The three solutions can be seen in this SageMath cell, painted in red, green and blue.
Welcome to Ask Sage! Thank you for your question.
Thanks for correcting the title :)