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.Sun, 10 Apr 2022 23:53:00 +0200implicit_plot3d string "\n" ignoredhttps://ask.sagemath.org/question/61904/implicit_plot3d-string-n-ignored/I *presume* other plot functions have the same problem.
code clip (I will set up a real executable if it will help)
lim=2
gl=implicit_plot3d(x^2+y^2+z^2==1,(x,-lim,lim),(y,-lim,lim),(z,-lim,lim),color='purple',mesh=True)
gl_a = ('test start'+"\n")
gl += text3d(gl_a + '\n test add'+"\n",[1,1,1] )
gl
Where gl is implicit_plot3d(...._)
I looked around and this works as expected (?)
text("Sage graphics are \n really neat because they use matplotlib!", (2,12))
Whereas this doesn't, I guess it's built in.
text3d("Sage graphics are \n really neat because they use matplotlib!", (2,12,3))
The print output is as intended, but gl plot ignores "\n"
Is there a special syntax for strings in plots?
Do I really have to add (and position) each line separately?
System: Ubuntu mate -- compiled 9.5
I wanted to provide portable and multiple HTML plot pages facilitating comparing plots, and provide enough information in the plots so that they describe themselves; more or less. So the id's don't get forgotten and lost.
Now that I think about it; there are special functions that, I think, said they would combine html "fragments" (what ever they are). Does anybody know about these programs? References are fine.rrogersSun, 10 Apr 2022 22:43:09 +0200https://ask.sagemath.org/question/61904/How to flip normals of Graphics3d faces?https://ask.sagemath.org/question/61908/how-to-flip-normals-of-graphics3d-faces/Is there an easy way to flip the normals for all the faces of a `sage.plot.plot3d.base.Graphics3d` or `sage.plot.plot3d.base.Graphics3dGroup` object?
I checked the source of https://github.com/sagemath/sage/blob/develop/src/sage/plot/plot3d/base.pyx but couldn't find any answers there.
### Background:
I am generating a 3-dimensional surface on the YZ plane via `sage.plot.plot.parametric_plot` using long-running functions and want to mirror this surface by the XY plane to produce a final mesh which includes both the original and mirrored surfaces.
mySurface = parametric_plot(
[
0,
lambda u, v: longRunningYFunction(u, v),
lambda u, v: longRunningZFunction(u, v)
],
...
)
The reason I want to mirror the original surface instead of regenerating it is because the long-running functions take a very long time to complete, so doing it this way effectively cuts down the processing time in half.
I tried a few ways to mirror the surface:
- Rotating by `180°` around the Y axis
mirroredSurface = mySurface.rotateY(pi)
- Scaling by `-1` in the Z direction:
mirroredSurface = mySurface.scale([1, 1, -1])
and when I display or write both surfaces it looks ok:
show(mySurface + mirroredSurface)
but when inspected more closely, the normals of `mirroredSurface` are in the opposite direction of `mySurface`. This requires me to manually flip the surfaces with Blender.
### Question:
Is there any extension or function I can apply on the `Graphics3d` object `mirroredSurface` that would flip all the surface normals?
Something like the following?
mirroredSurface.flip_normals()
# or
flip_normals(mirroredSurface)
Dan-KSun, 10 Apr 2022 23:53:00 +0200https://ask.sagemath.org/question/61908/refresh with three.jshttps://ask.sagemath.org/question/61806/refresh-with-threejs/In some analysis/education projects I would like to compare different situations; like the Kerr GR diagrams which have lots of moving parts (sorry for the pun).
Which is to say: generate plot(s) ⇾ save as HTML (s)(or some such) ⇾ open the file(s) with a browser.
Then change plot parameters and resave and have the open pictures update automatically. Actually, I presume that the three.js would have them monitoring the HTML file as in:
[Stack overflow here:](https://stackoverflow.com/questions/5588658/auto-reload-browser-when-i-save-changes-to-html-file-in-chrome)
although a triggered update would be fine, but that answer seems simple enough to put in the three.js (template?) myself.
I realize that I could do the update manually in the browser toolbar; but being distractible and forgetful, it would be better to have it automatic. Although I am open to other suggestions.
I really enjoy moving around the parameter space as well as objects, visually oriented :); and I think sagemath does wonderful plots.rrogersSun, 03 Apr 2022 22:54:13 +0200https://ask.sagemath.org/question/61806/Height of the output cell in 3D plotshttps://ask.sagemath.org/question/60188/height-of-the-output-cell-in-3d-plots/Is it possible to change the height of the output cell in 3d plots?
We can globally change the size of 2D plots with
Graphics().SHOW_OPTIONS.update({'figsize':[6,4]})
Is there something similar for 3d plots?cav_rtFri, 10 Dec 2021 02:07:40 +0100https://ask.sagemath.org/question/60188/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/