ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 22 Mar 2019 13:16:55 -05003D line from equations to parametrichttps://ask.sagemath.org/question/45870/3d-line-from-equations-to-parametric/ In 3D space, given a line defined as the solution of two equations (two planes intersection) like in:
sage: x,y,z=var('x y z')
sage: eqns = [x + y + 2*z - 25 == 0, -x + y - 25 == 0]
how to obtain the direction vector and one (any) line point (parametric form) ?
This solution from solve:
sage: solve( eqns, [x,y,z] )
[[x == -r13, y == -r13 + 25, z == r13]]
has an answer in parametric form, but with parameter "r13" that has a name unpredictable and not usable in next steps.
This solution from solve:
sage: solve( eqns, [y,z] )
[[y == x + 25, z == -x]]
solves the issues of the previous, but it has been assumed that "x" is a valid parameter for the line ( something not true, by example, in case of vertical line: [ x==10 , y==2 ] )
The target is, by example, to obtain a parametric expression of any line that after can be used in a call to "parametric_plot3d".
pasaba por aquiFri, 22 Mar 2019 13:16:55 -0500https://ask.sagemath.org/question/45870/Parametric 3d plot not showinghttps://ask.sagemath.org/question/39233/parametric-3d-plot-not-showing/ If I write `somePlot=parametric_plot3d((sin, cos, lambda u: u/10), (0,20))
somePlot.show()
`
Into a .sage file and therafter write `sage file.sage` it will not show anything. While if I run sage interactively from the terminal and write the same it will open jmol viewer and show the file. Why does this happen?PoetastropheFri, 20 Oct 2017 10:02:44 -0500https://ask.sagemath.org/question/39233/Color parametric_plot3d by a rgb color rather than a colormap.https://ask.sagemath.org/question/36386/color-parametric_plot3d-by-a-rgb-color-rather-than-a-colormap/ I know I can color a 3d plot using a function and a color map. What I would like to do is to color a plot using a function that return a rgb color directly.
Specifically, I am trying to plot complex functions on the Riemann sphere. I can show the argument using the HSV color map (which is incorrectly named since it only shows hue, not saturation nor value):
sproj(x,y,z) = (x + I*y)/(1-z)
cf = lambda u,v: N(arg(-f(sproj(cos(u)*cos(v),sin(u)*cos(v),sin(v))))/(2*pi)+0.5)
cm = colormaps.hsv
parametric_plot3d((cos(s)*cos(t),sin(s)*cos(t),sin(t)), (s,-pi,pi),(t,-pi/2,pi/2), color = (cf,cm))
This does not show the modulus, though. I would like to be able to do something like this:
sproj(x,y,z) = (x + I*y)/(1-z)
cf = lambda u,v: complex_to_rgb(-f(sproj(cos(u)*cos(v),sin(u)*cos(v),sin(v))))
parametric_plot3d((cos(s)*cos(t),sin(s)*cos(t),sin(t)), (s,-pi,pi),(t,-pi/2,pi/2), color = cf)Jan HlavacekWed, 25 Jan 2017 12:43:23 -0600https://ask.sagemath.org/question/36386/Plot periodic minimal surface from Weierstrass representationhttps://ask.sagemath.org/question/34848/plot-periodic-minimal-surface-from-weierstrass-representation/ I want to plot the Schwarz P-(rimary) surface using its Weierstrass representation. Here is the code:
var('rho,a,w')
R=(w*(w^6+7/4*sqrt(2)*w^3-1))^(1/2)
# R=-I*w^2
theta=0
Phi_1=((1-w^2)/R).integrate(w)
Phi_2=(I*(1+w^2)/R).integrate(w)
Phi_3=(2*w/R).integrate(w)
def FF1(rho,a):
return real_part(exp(I*theta)*Phi_1(w=rho*exp(I*a)))
def FF2(rho,a):
return real_part(exp(I*theta)*Phi_2(w=rho*exp(I*a)))
def FF3(rho,a):
return real_part(exp(I*theta)*Phi_3(w=rho*exp(I*a)))
parametric_plot3d([FF1,FF2,FF3],(rho,0.001,1),(a,0.001,pi/3-0.001))
The range of plot is chosen to avoid any singular points, otherwise there will be a division-by-zero error. The commented line is a test for helicoid, which works very well. However, for P-surface, it returns the following warning:
.../sage/local/lib/python2.7/site-packages/sage/repl/rich_\
output/display_manager.py:590: RichReprWarning: Exception in _rich_repr_
while displaying object:
'sage.rings.complex_double.ComplexDoubleElement' object has no attribute
'variables'
RichReprWarning,
Graphics3d Object
And no graphics displayed.Hao ChenSun, 18 Sep 2016 03:04:22 -0500https://ask.sagemath.org/question/34848/How to plot a 3D Triangle (prism) using parametric_plot3dhttps://ask.sagemath.org/question/33571/how-to-plot-a-3d-triangle-prism-using-parametric_plot3d/ I need to plot a 3d Triangle (prism), but i dont have any idea of how to make it. I try a lot of things but didn't work, please help me. ivanyosefSat, 28 May 2016 14:33:05 -0500https://ask.sagemath.org/question/33571/Funny ellipsehttps://ask.sagemath.org/question/33447/funny-ellipse/ I am trying to plot an ellipse (using the term loosely). I want the set of points equidistant from the plane defined parametrically by (0, 0, 1) + t(0, 1, 1) + s(1, 1, 1).
It is intuitive that this is just the union of two parallel planes. But when I plot, I get an oval...what is wrong? Note that uncommenting to change the vectors gives two planes as expected, furthering my bewilderment.
posvec = vector([0, 0, 1])
# posvec = vector([1, 1, 1])
dirvec1 = vector([1, 1, 0])
# dirvec1 = vector([-1, 2, 0])
dirvec1 = dirvec1 / dirvec1.norm()
dirvec2 = vector([1, 1, 1])
# dirvec2 = vector([3, 0, -7])
dirvec2 = dirvec2 / dirvec2.norm()
point = vector([x, y, z])
relpos = point - posvec
disvec = relpos - relpos.dot_product(dirvec1) * dirvec1 - relpos.dot_product(dirvec2) * dirvec2
dis = disvec.norm()
radius = 10
my_ellipse = implicit_plot3d(10 - dis, (x, -15, 15), (y, -15, 15), (z, -15, 15), opacity = 0.3)
s, t = var('s, t')
my_focus = parametric_plot3d(posvec + t * dirvec1 + s * dirvec2, (t, -15, 15), (s, -15, 15), opacity = 0.3, color = 'red')
my_pic = my_focus + my_ellipse
my_picTumericTJWed, 18 May 2016 22:31:21 -0500https://ask.sagemath.org/question/33447/Error rendering 3d scenehttps://ask.sagemath.org/question/29510/error-rendering-3d-scene/I'm working in the SageMath Cloud. The code block
x,y,t = var('x,y,t')
f = lambda x,y: x*abs(y)/sqrt(x^2+y^2) if (x,y)<>(0,0) else 0
a,b = 1,6
e = 0.1
parametric_plot3d( [b*t, -a*t, f(b*t,-a*t)], [t,-e,e], color="yellow", size=15 )
produces an error message:
error rendering 3d scene -- error downloading /blobs/682b952d-d577-45ce-98ff-4e7a06ddad32.sage3d?uuid=682b952d-d577-45ce-98ff-4e7a06ddad32
But if I change the fourth line to `e = 1`, then it works just fine.
A similar error was reported in http://ask.sagemath.org/question/27300/error-rending-3d-scene, but the fix there was easier.
Jeremy MartinSun, 20 Sep 2015 07:03:28 -0500https://ask.sagemath.org/question/29510/Boundaries for parametric_plot3d?https://ask.sagemath.org/question/30757/boundaries-for-parametric_plot3d/Is it possible to specify the bounding box of the output of a call to parametric_plot3d?
I am trying to produce animations of Frenet frames. The following code 'works' more or less, but in each frame sage changes the bounding box slightly, producing less than ideal results. If I have to resort to plotting some kind of bounding object with opacity set to 0, then so be it, but I am hoping for a more elegant solution.
t = var('t')
x(t) = (cos(3*t)+2)*cos(2*t)
y(t) = (cos(3*t)+2)*sin(2*t)
z(t) = -sin(3*t)
gamma = vector([x,y,z])
def length(v):
return sqrt(v[0]^2+v[1]^2+v[2]^2)
a = 0
b = 2*pi
P = parametric_plot3d(gamma(t),(t,a,b),frame=False)
T = gamma.diff(t)/length(gamma.diff(t))
N = T.diff(t)/length(T.diff(t))
B = T.cross_product(N)
def frame(t):
return P + arrow(gamma(t),gamma(t)+T(t),color='green',frame=False) + arrow(gamma(t),gamma(t)+N(t),color='red',frame=False) + arrow(gamma(t),gamma(t)+B(t),color='purple',frame=False)
num_frames = 10
frenet_movie = animate([frame(tt) for tt in srange(a,b,(b-a)/num_frames)])
frenet_movie.show()
(You can up num_frames if you want a smoother movie, though these take a while to render. The length function is defined because the `normalized()` method was producing lots of strange errors, namely with sage claiming it could not produce numerical approximations of the vectors involved....)Kyle OrmsbyMon, 16 Nov 2015 10:57:47 -0600https://ask.sagemath.org/question/30757/parametric_plot3d fails with floating-point parameterhttps://ask.sagemath.org/question/26329/parametric_plot3d-fails-with-floating-point-parameter/The following code
u,v = var('u,v')
X = u * cos(v) - (1/3)* u^3 * cos(v*3)
Y = - u * sin(v) - (1/3) *u^3 * sin(3*v)
Z = u^2 *cos(2*v)
p = parametric_plot3d([X,Y,Z], (u,0,1),(v,0,2*pi),frame=False, color="blue")
works but with 0.9 in place of 1 in range of u produces an error. Namely,
Unhandled SIGILL: An illegal instruction occurred in Sage.
This probably occurred because a *compiled* component of Sage has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Sage will now terminate.
beesonWed, 25 Mar 2015 13:28:58 -0500https://ask.sagemath.org/question/26329/Transferring 3D plotshttps://ask.sagemath.org/question/26075/transferring-3d-plots/I want to export 3D plots from Sage in some 3D format or other (NOt just a single png frame)
This script produces a jMol file for me. (I am on cloud.sagemath)
> from sage.interfaces.jmoldata import JmolData 3 sage: JData = JmolData() 4
> u,v = var('u v') 5 f_x = u 6 f_y =
> cos(1*v) 7 f_z = sin(3*v) 8
> img=parametric_plot3d([f_x, f_y, f_z],
> (u, 0, 0.6), (v, 0, 6*pi),
> color='blue', mesh=1, frame=False) 9
> img.save('myfile.png') 10
> img.export_jmol('thisjmol') 11 img 12
The file produced is about 20K or so but if I try to open it via JMol standalone viewer I just get black.
Mind you if I try the example jmols I also get black.
My end point is to get the 3D view into a 3D package such as Blender but to start with I need to get my 3D image out of sage.
Any idea of where I am going wrong?
nerak99Sun, 08 Mar 2015 12:56:45 -0500https://ask.sagemath.org/question/26075/save (and reuse) parametric_plot3d objecthttps://ask.sagemath.org/question/24390/save-and-reuse-parametric_plot3d-object/Hello,
I am a total newbie in Sage and I do not talk Python :-(
I was just trying to draw some surfaces for illustration when I came across a problem loading my saved computations.
NotImplementedError: You must override the get_grid method.
(code below.)
Is there a way to do what is suggested (override...)?
I found a bug ticket
[http://trac.sagemath.org/ticket/9957](http://trac.sagemath.org/ticket/9957)
and saw
[http://ask.sagemath.org/question/7704/importing-saved-3d-plot/](http://ask.sagemath.org/question/7704/importing-saved-3d-plot/)
I am not very hopeful, but since I basically do not understand what's written, maybe there's a way to override get-grid as the error message says.
Is there?
If not, is there a way to convert to an object that can be saved (and at least displayed again) or export it to an external format?
Thank you,
bb16
code:
sage: pam2=load(DATA+'pam2imt5000.sobj')
sage: type(pam2)
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\verb|<type|\phantom{\verb!x!}\verb|'sage.plot.plot3d.parametric_surface.ParametricSurface'>|</script></html>
sage: show(pam2)
Traceback (most recent call last):
...
NotImplementedError: You must override the get_grid method.
sage: load(DATA+'pam3imt5000.sobj')
Traceback (most recent call last):
...
NotImplementedError: You must override the get_grid method.
bb16Sat, 04 Oct 2014 04:36:58 -0500https://ask.sagemath.org/question/24390/Bound box for parametric 3D plots?https://ask.sagemath.org/question/10912/bound-box-for-parametric-3d-plots/I am trying to plot a parametric surface but only in a certain box in 3D space. Namely, I would like to get JMol to plot this:
var('s t')
p = [s^2, s^2+t^2, s^2+s*t+s+t]; q = s^2+t^2+s-t+1
parametric_plot3d((p[0]/q,p[1]/q,p[2]/q),(s,-5,5),(t,-5,5), points=[100,100])
but restricted to [0,1]x[0,1]x[0,1] (for example). I see that implicit plots work exactly like that, but the singular part of this surface looks quite ugly: [http://imgur.com/5IxilIz](http://imgur.com/5IxilIz "img").
I would be fine with tachyon too, but I haven't been able to figure out how to rotate the camera (I basically want to cut out a chunk of that surface to see a section).davidsevillaTue, 14 Jan 2014 01:25:21 -0600https://ask.sagemath.org/question/10912/Mesh not appearing on 3d plothttps://ask.sagemath.org/question/8833/mesh-not-appearing-on-3d-plot/I'm trying to get a mesh to appear on a surface in Sage 4.8 using `parametric_plot3d`. Here is the code:
var('u,v')
f=[u-u^3/3+u*v^2,-v+v^3/3-v*u^2,u^2-v^2]
parametric_plot3d(f,(u,-7,7),(v,-7,7),opacity=0.7,mesh=True)
What am I doing wrong? I also can't get any of the examples from the tutorial page to show a mesh.
calc314Wed, 28 Mar 2012 04:29:26 -0500https://ask.sagemath.org/question/8833/Variable parameter range in parametric_plot3d?https://ask.sagemath.org/question/8828/variable-parameter-range-in-parametric_plot3d/Is it possible to give parametric_plot3d parameter ranges where one parameter is a function of the other? For example, I would like the following command to execute and create a plot of a triangle in $\mathbb{R}^3$.
v = some vector
w = some other vector
someTriangle = parametric_plot3d(t*v + s*w, (t,0,1-s), (s,0,1))
Thanks!BillMon, 26 Mar 2012 16:20:20 -0500https://ask.sagemath.org/question/8828/using @interacthttps://ask.sagemath.org/question/8757/using-interact/I have this code which works just fine and produces an image:
var('u')
center(x) =sqrt(x)
spin(x) = 2- 1/4 * x^2
r(x) = abs(spin(x) - center(x))
parametric_plot3d((x, r(x)*sin(u)+center(x), r(x)*cos(u)), (u, 0, 2*pi), (x, 0, 2), mesh=True)
However, I would like to use a @interact to be able to change the functions named center and spin. I tried this (and a few variations)
@interact
def _(center =6 -x^2, spin = x):
var('u')
var('t')
r(x) = abs(spin(x) - center(x))
parametric_plot3d((t, r(t)*sin(u)+center(x=t), r(t)*cos(u)), (u, 0, 2*pi), (t, 0, 2), mesh=True)
and while I don't get an error, I also don't get a picture for some reason. Any suggestions?
PwnasaurusWed, 29 Feb 2012 08:55:20 -0600https://ask.sagemath.org/question/8757/How to populate face_list without using show()?https://ask.sagemath.org/question/8519/how-to-populate-face_list-without-using-show/Is there a way to populate the face_list attribute of the result of parametric_plot3d without showing the plot itself? I am running a script to generate a lot of these surfaces, and I am not interested in closing the jmol window for each surface.
Thanks!BillSun, 04 Dec 2011 10:58:58 -0600https://ask.sagemath.org/question/8519/parametric plotting over regions bounded by two curves in the planehttps://ask.sagemath.org/question/8361/parametric-plotting-over-regions-bounded-by-two-curves-in-the-plane/Hi all,
Maple's parametric plot3d command allows the limits of the second of the two parameters to
be functions of the first. For example, to plot the intersection of two circular cylinders enter
c1 := plot3d([cos(t), y, sin(t)], t = 0 .. 2*Pi, y = -sin(t) .. sin(t), color = green)
c2 := plot3d([cos(t), sin(t), z], t = 0 .. 2*Pi, z = -sin(t) .. sin(t), color = blue)
display(c1, c2)
This generates a plot of the intersection region with the portions of the cylinders extending
beyond the region removed. Is it possible todo the same with Sage's plot3d commands?
Regards,
Adam Hausknecht
ahausknechtSat, 08 Oct 2011 07:08:35 -0500https://ask.sagemath.org/question/8361/Viviani's Curvehttps://ask.sagemath.org/question/8122/vivianis-curve/Hello!
How can I plot Viviani's curve in Sage onto cylinder and sphere?
My problem is putting sphere into or inside cylinder and then put Viviani's Curve on this.
here is example
[http://upload.wikimedia.org/wikipedia/commons/0/05/Viviani_curve.png](http://upload.wikimedia.org/wikipedia/commons/0/05/Viviani_curve.png)AlexxxThu, 19 May 2011 05:18:07 -0500https://ask.sagemath.org/question/8122/