Ask Your Question
0

setting bounds for parametric-plot3d

asked 2019-11-19 16:53:05 +0100

PierreArnoux gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2019-11-19 19:11:45 +0100

FrédéricC gravatar image

For 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)
edit flag offensive delete link more
0

answered 2019-11-21 00:45:27 +0100

Juanjo gravatar image

updated 2019-11-21 12:35:24 +0100

The 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. 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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-11-19 16:53:05 +0100

Seen: 555 times

Last updated: Nov 21 '19