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.Thu, 21 Nov 2019 00:45:27 +0100setting bounds for parametric-plot3dhttps://ask.sagemath.org/question/48810/setting-bounds-for-parametric-plot3d/ I am trying to represent the part of a parametric surface contained in a cube of given coordinates. What I would like to do is to first compute a large part of the surface, then clip it to the given cube.
I do not see how to do that; there is an option bounding_box(), but I did not find any documentation on it, and I do not understand what it does.Tue, 19 Nov 2019 16:53:05 +0100https://ask.sagemath.org/question/48810/setting-bounds-for-parametric-plot3d/Answer by FrédéricC for <p>I am trying to represent the part of a parametric surface contained in a cube of given coordinates. What I would like to do is to first compute a large part of the surface, then clip it to the given cube.
I do not see how to do that; there is an option bounding_box(), but I did not find any documentation on it, and I do not understand what it does.</p>
https://ask.sagemath.org/question/48810/setting-bounds-for-parametric-plot3d/?answer=48812#post-id-48812For a treatment after creating the plot, there is now "add_condition"
x,y,z = var('x,y,z')
P = implicit_plot3d(z-x*y,(-2,2),(-2,2),(-2,2))
def condi(x,y,z):
return bool(x*x+y*y+z*z <= Integer(1))
P.add_condition(condi,8)Tue, 19 Nov 2019 19:11:45 +0100https://ask.sagemath.org/question/48810/setting-bounds-for-parametric-plot3d/?answer=48812#post-id-48812Answer by Juanjo for <p>I am trying to represent the part of a parametric surface contained in a cube of given coordinates. What I would like to do is to first compute a large part of the surface, then clip it to the given cube.
I do not see how to do that; there is an option bounding_box(), but I did not find any documentation on it, and I do not understand what it does.</p>
https://ask.sagemath.org/question/48810/setting-bounds-for-parametric-plot3d/?answer=48830#post-id-48830The key is the `add_condition` method already mentioned by @FrédericC in his answer. Anyway, since the O.P. deals with *parametric surfaces*, I provide a complete example:
var("u,v")
S = parametric_plot3d(((2+cos(v))*cos(u), (2+cos(v))*sin(u), sin(v)), (u,0,2*pi), (v,0,2*pi))
S.show(viewer="threejs")
p1 = (-3,-2,-1)
p2 = (3,2,0.5)
def cond(*xyz):
return all([t[0]<=t[1]<=t[2] for t in zip(p1,xyz,p2)])
S.add_condition(cond,50).show(viewer="threejs")
This code first shows a torus, then the same torus clipped by the box determined by two given points `p1` and `p2`. See this [SageMath Cell](https://sagecell.sagemath.org/?z=eJx1TssKwjAQvPcrlp42dSttihexX-GxFAlNxEhNQprGx9ebCIIX97A7s8vOTBQey5ViyYoj9OCEFzcVvJ5Obrahk4jIN5NdMDJW5bkygp_Vos1nlWfi6bZSQ7xyOuP4xUl9u1zsHaNWd-X7Mly8Utcl2bo2-WLdUc2pbhPnmXfEqdnuWCHVGSZrJFaP54vtC0jlVVi9ATHPOIShGQ99GNpP5yOcrYcA2sBLO3QtpTdynI05gpDylMV00NZgRrRr2J9kbyyTU-0=&lang=sage&interacts=eJyLjgUAARUAuQ==). Concerning the second argument of `add_condition`, the docs indicates that it is the number of steps used on the boundary to cut the triangles that are not entirely within the domain; the larger this argument is, the smoother the boundary is.Thu, 21 Nov 2019 00:45:27 +0100https://ask.sagemath.org/question/48810/setting-bounds-for-parametric-plot3d/?answer=48830#post-id-48830