MrGas
MrGas

Reputation: 11

Motion of a point on a curve in Mathematica

I've been given an assigment to create an animation (in Mathematica) of a point moving along a curve created by the common part of an ellipsoid and a plane.

I've made the following as good as I could but I'm stuck.

Image

The formula(?) for the ellipsoid surface and plane:

Upvotes: 0

Views: 904

Answers (1)

ewcz
ewcz

Reputation: 13087

you could use ContourPlot to generate the curve, then extract the points representing the curve and use Manipulate to generate the animation, i.e.,

P = ContourPlot[x^2/4 + y^2/9 + (-x + 2*y)^2 == 1, {x, -3, 3}, {y, -3, 3}];

(* let's (ab)use the points *)
pnts = P[[1, 1]];

Manipulate[
    Show[
         P,
         ListPlot[pnts[[i ;; i]], PlotStyle -> {PointSize -> Large, Red}]
    ], {i, 1, Length[pnts], 1}
 ]

Then the individual frames look like this:

enter image description here

Further, one could continue with a "3D" attempt as

pnts3D = {#[[1]], #[[2]], -#[[1]] + 2*#[[2]]} & /@ pnts;
Animate[
    Graphics3D[{Opacity[0.5], Ellipsoid[{0, 0, 0}, {2, 3, 1}], 
    Opacity[0.75], InfinitePlane[{{1, 0, -1}, {0, 0, 0}, {0, 1, 2}}], 
    Opacity[1], Red, PointSize[Large], Point[pnts3D[[i ;; i]]]}]
, {i, 1, Length[pnts3D], 1}]

Here, the equation of the plane is used in order to uniquely generate the z coordinate.

Upvotes: 2

Related Questions