Ask Your Question

plot the the intersection of two surfaces in 3d, use of a special colour for the intersection

asked 2022-10-22 11:18:22 +0100

Tintin1 gravatar image

updated 2022-10-22 11:20:08 +0100

Is it possible to colour the intersection of two surfaces in 3d with a special colour in the following plot?

x, y, z = var('x,y,z')
surface1 = implicit_plot3d(f1,(x,-5,5),(y,-3,3), (z,-5,5), color='blue',opacity=1)
surface2 = implicit_plot3d(f2,(x,-5,5),(y,-3,3), (z,-5,5), color='red',opacity=.3)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-10-22 16:33:09 +0100

Emmanuel Charpentier gravatar image

The "numerical" solution will be slow and artefactual (the rate of variatuns of x, y and z are wildly different, and "one-size-fits-all" plot_points will actually fit none...) :

var("x, y, z")
f1(x, y, z)=y-x^3
f2(x, y, z)=z-x^5
S1=implicit_plot3d(f1, (-5, 5), (-3, 3), (-5, 5), color="blue", opacity=0.5, plot_points=200)
S2=implicit_plot3d(f2, (-5, 5), (-3, 3), (-5, 5), color="red", opacity=0.5, plot_points=200)
f3(x, y, z)=f1(x, y, z)^2+f2(x, y, z)^2-0.01
S3=implicit_plot3d(f3, (-5, 5), (-3, 3), (-5, 5), color="green", opacity=1, plot_points=200)

You can visualize by displaying S1+S2+S3. Ugly...

Better (but more work) to solve for y and z, and plot parametrically wrt x :

Sol=solve([f1(x, y, z), f2(x, y)], (y, z), solution_dict=True)
A3 = parametric_plot3d([x, Sol[0][y], Sol[0][z]], (x, -5^(1/5), 5^(1/5)), color="green")

S1+S2+A3 is faster and better-looking...

More general case : solve z as a function (possibly multi-valued) of x and y and plot3d the result...


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

1 follower


Asked: 2022-10-22 11:18:22 +0100

Seen: 113 times

Last updated: Oct 22 '22