6
$\begingroup$

Surface

z = 2 x^3 - 5 y^4

Plane

z = x + y + 5

Plot

enter image description here

A curve is formed by the intersection of the surface and the plane. I would like to add a point to the plot that can be moved by the user along the curve of intersection.


Thanks!!!

to work animation, i had to change line

anim = Table[
   Show[p3D, Graphics3D[{PointSize[0.02], Point[par[j]]}], 
    ViewPoint -> {-1, -1, 1}], {j, -10, 10, 0.1}];

to:

Animate[Show[p3D,Graphics3D[{PointSize[0.02],Point[par[j]]}],ViewPoint->{-1,-1,1}],{j,-10,10,0.1}]

But where is equation of motion of the material point in this solution?

$\endgroup$
3
  • $\begingroup$ And have you looked up the documentation page for Manipulate? $\endgroup$
    – march
    Commented Jun 14, 2016 at 22:46
  • 1
    $\begingroup$ Fully agree with @march. Try to use Solve to figure out the function of crossing, then use Manipulate to show it. $\endgroup$
    – Wjx
    Commented Jun 14, 2016 at 23:33
  • $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$
    – Michael E2
    Commented Jun 18, 2016 at 22:27

3 Answers 3

11
$\begingroup$

You can use MeshFunctions to visualize the intersection. The following is one way to parametrize curve.

f[x_, y_] := 2 x^3 - 5 y^4;
p[x_, y_] := x + y + 5;
expr = x /. Quiet[First@Solve[f[x, y] == p[x, y], {x, y}, Reals]];
t[u_] := expr /. y -> u;
par[w_] := {t[w], w, p[t[w], w]};
p3D = Plot3D[{f[x, y], p[x, y]}, {x, -20, 20}, {y, -10, 10}, 
   MeshFunctions -> (f[#1, #2] - p[#1, #2] &), Mesh -> {{0}}, 
   MeshStyle -> {Red, Thick}, PlotStyle -> Opacity[0.5]];
anim = Table[
   Show[p3D, Graphics3D[{PointSize[0.02], Point[par[j]]}], 
    ViewPoint -> {-1, -1, 1}], {j, -10, 10, 0.1}];

enter image description here

$\endgroup$
1
$\begingroup$

A modification of @ubpdqn's approach using MeshFunctions to show the boundary of the two surfaces:

We can use a function as the setting for MeshStyle. Doing so we can inject additional primitives (e.g., Spheres) using the coordinates of mesh lines. Using Clock + Dynamic, we can make these additional primitives dynamic.

meshStyle = {Red, Thick, #, Opacity[1], Specularity[Yellow, 50], Green, 
   Dynamic @ Sphere[#[[1, Clock[{1, Length[#[[1]]], 1}, 5]]], 1]} &;

f[x_, y_] := 2 x^3 - 5 y^4;
p[x_, y_] := x + y + 5;

Show[Plot3D[f[x, y], {x, -20, 20}, {y, -10, 10}, 
  MeshFunctions -> (f[#1, #2] - p[#1, #2] &), Mesh -> {{0}}, 
  MeshStyle -> meshStyle, PlotStyle -> Opacity[0.5], 
  BoundaryStyle -> None, Axes -> False, ImageSize -> Large], 
 Plot3D[p[x, y], {x, -20, 20}, {y, -10, 10}, Mesh -> None, 
  BoundaryStyle -> None,  PlotStyle -> Opacity[.2, Blue]], 
 Lighting -> "Neutral"]

enter image description here

Note: The price we pay is to plot the two surfaces separately. If we use a single Plot3D with two functions in the first argument, then we get two mesh lines (one for each surface) that do not necessarily have identical coordinates and using MeshStyle -> meshStyle gives double spheres.

$\endgroup$
1
$\begingroup$

We can construct the parametric curve g[y] by using y as variable and only use ParametricPlot3D.

f[x_, y_] = 2 x^3 - 5 y^4;
p[x_, y_] = x + y + 5;
g[y_] = Block[{x}, {x, y, p[x, y]} /. 
    Solve[f[x, y] == p[x, y], x, Reals]];
fig1 = Plot3D[{p[x, y], f[x, y]}, {x, -20, 20}, {y, -10, 10}, 
   PlotStyle -> Opacity[.2], Mesh -> None];
fig2 = ParametricPlot3D[g[y], {y, -10, 10}, PlotStyle -> Red];
Manipulate[
 Show[fig1, fig2, Graphics3D[{PointSize[.03], Point[g[y]]}], 
  Boxed -> False, Axes -> False], {{y, -5}, -10, 10}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.