ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 03 Nov 2021 17:02:13 +0100how to plot Riemann surfacehttps://ask.sagemath.org/question/59581/how-to-plot-riemann-surface/ Hi
I would like to plot this Riemann surface with SageMath:
![Riemann surface ](/upfiles/16359552166374623.gif)
ortolljWed, 03 Nov 2021 17:02:13 +0100https://ask.sagemath.org/question/59581/Is there a way to define a submanifold of a Euclidean space by providing a list of implicit constraints, instead of by declaring a separate manifold and explicitly defining the embedding?https://ask.sagemath.org/question/56534/is-there-a-way-to-define-a-submanifold-of-a-euclidean-space-by-providing-a-list-of-implicit-constraints-instead-of-by-declaring-a-separate-manifold/**Reasons for asking:** My ultimate goal is to be able to integrate vector and form fields on surfaces defined by constraints in a 3D Euclidean space. A simple example would be the sphere (x^2 + y^2 + z^2 = R^2). perfectly_oddWed, 07 Apr 2021 20:09:41 +0200https://ask.sagemath.org/question/56534/Path rendering on a Surfacehttps://ask.sagemath.org/question/54279/path-rendering-on-a-surface/I am having a discrepancy with the z-coordinates of a path on a surface.
The blue path shown below is correctly embedded in the red surface.
The z-coordinates for the green path are "almost" correct. I have gone over the math dozens of times. I need to compute rational powers of cosine and sine. Wondering if it could be a rounding issue?
The surface is parametrized in polar coordinates.
The path is parametrized in rectangular coordinates. (This is because on the full surface this portion is shifted along the x-axis. I reparametrized it polar and it seems less accurate).
What I've done is:
1. Specify the path as $(x(u), y(u))$
2. Compute the radial distance to the point $r(u) = \sqrt{x^2 + y^2}$
3. The path is then given by $(x(u), y(u), z(r(u))$
(I've used the parameter $v$ to give the paths some "thickness")
This works fine for blue, not for green.
The surface height grows linearly with the radius.
The blue path's radius decays linearly.
The green path's radius decays non-linearly. But, I don't think that should matter, as I'm simply getting a list of points and plugging them into the height function.
u, v = var('u, v')
right_curve_u = 8+(14/pi)*(u+pi/2) #8+(14/pi)*(phi+pi/2)
f_x(u, v) = v*cos(u)
f_y(u, v) = v*sin(u)
f_z(u, v) = (((v-16)/12)*(12*cos((pi/11)*(right_curve_u - 17)) + 39.5))/12
T=parametric_plot3d([f_x, f_y, f_z], (u, -pi/2, 0), (v, 16, 28), color="red", opacity=0.5, axes=True, mesh=False)
#c=parametric_plot3d([f_x, f_y, f_z], (u, -pi/2, pi/2), (v, 21.9, 22.1), color="black", mesh=True)
#c is the curve in the first example with constant radius
#Path Equation; Note, "u" is the parameter for the path, "v" is to give it a bit of "thickness"
right_curve_u = 8+(14/pi)*(u+pi/2) #8+(14/pi)*(phi+pi/2)
right_curve_x(u,v) = v*(16*(cos(u))^(5/6))
right_curve_y(u,v) = v*(-28*(sin(-u))^(5/6))
#right_curve_path_radius(u,v) = v*(16*28)/(((28*cos(u))^(2.4)+(16*sin(-u))^2.4)^(5/12))
right_curve_path_radius(u,v) = sqrt((right_curve_x)^2+(right_curve_y)^2)
right_curve_path_radius_2(u,v) = v*sqrt((16^2)*(cos(u))^(5/3)+(28^2)*(sin(-u))^(5/3))
right_curve_z(u,v) = ( ( (right_curve_path_radius - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u - 17) ) + 39.5 ) )/12
right_curve_z_2(u,v) = ( ( (right_curve_path_radius_2 - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u - 17) ) + 39.5 ) )/12
right_curve = parametric_plot3d([right_curve_x, right_curve_y, right_curve_z], (u, -pi/2, -0.01), (v, 0.99, 1.01), color="black")
right_curve_2 = parametric_plot3d([right_curve_x, right_curve_y, right_curve_z_2], (u, -pi/2, -0.01), (v, 0.99, 1.01), color="green")
g_x(u, v) = v*(16-(12*(u-pi/2)/pi))*cos(u)
g_y(u, v) = v*(16-(12*(u-pi/2)/pi))*sin(u)
h(u) = v*(16 - (12/pi)*(u-pi/2))
g_z(u,v) = ( ( (h - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u - 17) ) + 39.5 ) )/12
c_xy=parametric_plot3d([g_x, g_y, g_z], (u, -pi/2, 0), (v, 0.99, 1.01), color="blue")
T+c_xy+right_curve+right_curve_2Abbas JaffaryWed, 18 Nov 2020 19:59:27 +0100https://ask.sagemath.org/question/54279/Vertex list of a surface not readily accessiblehttps://ask.sagemath.org/question/51608/vertex-list-of-a-surface-not-readily-accessible/ While preparing my answer to [this question](https://ask.sagemath.org/question/51567/how-to-plot-projections-of-a-3d-surface-onto-coordinate-planes/), I have been searching how to retrieve faces and vertices from a explicit surface plotted with `plot3d`. There is a fact that confuses me. Consider this code:
sage: surf = plot3d(lambda x,y: sin(x*y), (-pi,pi), (-pi,pi))
sage: len(surf.vertex_list())
0
This means that `surf.vertex_list()` is an empty list. However:
sage: surf = plot3d(lambda x,y: sin(x*y), (-pi,pi), (-pi,pi))
sage: show(surf)
Launched html viewer for Graphics3d Object
sage: len(surf.vertex_list())
1600
Now `surf.vertex_list()` is not an empty list and the vertices can be retrieved. So I wonder what `show(surf)` internally does so that the vertices list becomes accessible. To avoid plotting the surface, I have found that I can replace `show(surf)` by `surf.triangulate()`, but I also wonder if there is a best option.JuanjoThu, 28 May 2020 15:58:33 +0200https://ask.sagemath.org/question/51608/Intersection of implicitely defined surfaceshttps://ask.sagemath.org/question/47944/intersection-of-implicitely-defined-surfaces/ Is there a general way to visualize the space curve defined by the intersection of 2 implicitely defined surfaces?
I know, this has been discussed here before with the following suggested solutions:
1. Visualize all equations in the same plot - this has the disadvantage that surfaces - even if opaque, distract attention and may obstruct the view on the intersection curves
2. Combine the defining equations into a system of euations and solve it, present the solutions as parametric plots - this doesn't work with complex surfaces where Sage cannot solve the system.
I know, some 3D objects have an intersection() method, but apparently not those generated by implicit_plot3d.
But maybe, someone has another solution?
IngoMon, 16 Sep 2019 22:36:53 +0200https://ask.sagemath.org/question/47944/Discontinuous surface color by z-levelhttps://ask.sagemath.org/question/46541/discontinuous-surface-color-by-z-level/Hi there,
I want to plot a surface $z=f(x,y)$ together with the level curves (side by side). I know how to doi it when $f$ is continuous, or even bounded, but I run in trouble for uglier functions. Here are two examples (in CoCalC : a few things need to be adapted to use Jupyter) : the first works
var('x,y,s,t')
h(x,y)= x*y^2/(x^2+y^4)
cm = colormaps.Blues
def c(x,y):
return 0.6+x*y^2/(x^2+y^4+0.005)# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
show(S)
C=contour_plot(h, (x,-1, 1), (y,-1, 1),cmap='Blues',linestyles='solid', colorbar=True)
show(C,figsize=4)
While the second, below, does not work as I would like to
h(x,y)= y/(x^2+y^2)
cm = colormaps.Spectral
def c(x,y):
return float(y/(x^2 + y^2+0.005))# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
show(S, frame_aspect_ratio=[20,20,1])
C=contour_plot(h,(x,-1.5,1.5),(y,-1.5,1.5), cmap = "Spectral",
contours = [-2,-1, -0.5,-0.25,0,0.25,0.5,1,2], colorbar = True,
axes = True,
labels = True, label_colors='black',
label_inline=True, label_fontsize=8,
gridlines = True, axes_labels=['$x$','$y$'])
show(C,figsize=8)
I tried a few things, among other, what can be found https://ask.sagemath.org/question/7581/use-a-colormap-for-implicit_plot3d/[here (old post)](https://ask.sagemath.org/question/7581/use-a-colormap-for-implicit_plot3d/), but the discontinuity seems to cause some problems.
Suggestions?JCThu, 16 May 2019 03:12:51 +0200https://ask.sagemath.org/question/46541/load data file to draw surfacehttps://ask.sagemath.org/question/24589/load-data-file-to-draw-surface/ I have a matrix consisting of 512 rows and 512 columns. I have written this matrix down into a text file. Each cell of the matrix contains a positive value. I want to plot these values in 3 dimensional system to form a surface by uploading the text file. How to do it in sage ?
Thank youAvijitThu, 23 Oct 2014 10:56:20 +0200https://ask.sagemath.org/question/24589/Wireframe surface diagramshttps://ask.sagemath.org/question/10362/wireframe-surface-diagrams/I can plot a simple surface with
plot3d(x^2-y^2,(x-2,2),(y,-2,2))
which gives me a nice Jmol rendered surface. But what I can't find out is how to draw the same surface with wireframes (including hidden lines). Thanks!AlasdairThu, 18 Jul 2013 22:27:27 +0200https://ask.sagemath.org/question/10362/different color on backside of surfacehttps://ask.sagemath.org/question/10290/different-color-on-backside-of-surface/Hey,
I want to animate a 3D plot. Therefore I generate tachyon rendered implicit plots which I then send to ffmpeg. This works quite well. The only disadvantege, is that it's during the video hard to distinguish which side of the surface one sees. Therefore I want to change the color of the backside or at least increase the shadow.
I already tried some stuff with the tachyon raytracer building a scene. But this does not work for implicit plots. The solution given [here](http://ask.sagemath.org/question/20/the-tachyon-object-used-for-rendering-plots) seems not to be very usefull in this context.
Is there perhaps a simply trick, which does the job?
ThorstenWed, 26 Jun 2013 17:38:03 +0200https://ask.sagemath.org/question/10290/