-3

I have an equation for a sphere which is x^2 +y^2 + (z - 1)^2 == 1 and for a sinusoid which is y == Sin[x] with z == 0.

I need to make a 3D animation that shows the sphere being cut in half by the sinusoid. Intersection of these two will be the trajectory for another sphere which will follow it.

[EDIT] In the most simple way it should look like this but should be an animation. In this example i haven`t used any equations but y=sin[x] and x=3.

Show[Graphics3D[{Red, Sphere[{0, -0.5, 0}, 0.2]}], Plot3D[y = Sin[x], {x, -5, 5}, {y, -1, Sin[x]}]]

Twardy
  • 11
  • 2
  • You might be interested in this. – J. M.'s missing motivation Jun 07 '16 at 19:05
  • It is very close to the one i need. Third example with sphere is similar to one i have received by using show and graphics3D,Plot3d but still it must be animated with point going along intersection and this is the main problem for me – Twardy Jun 07 '16 at 19:12
  • Could you make a graphic of the current state of affairs? When I plot the sphere and the line y=Sin[x] with z=0, I get a curve that intersects the sphere at a single point, i.e., {0,0,0}. I think that I am not understanding the question. Here is the code to plot the sphere and line: Show[ ContourPlot3D[ x^2 + y^2 + (z - 1)^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, 0, 2}, ColorFunction -> Function[{x, y, z, f}, {Orange, Opacity[0.2]}]], Graphics3D[{ Thick, Line[Table[{x, Sin[x], 0}, {x, -1, 1, 0.02}]] }] ] – Jack LaVigne Jun 08 '16 at 01:35
  • The description *with z == 0* is at odds with the code you have used to plot the graphic. You need to work at re-formatting the question. I suggest you also add the graphic your code produces as an image. You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. – Jack LaVigne Jun 08 '16 at 12:46

1 Answers1

5

I admit that I am uncertain what the aim is. I post this with the hope that it may prompt correction/clarification with respect to the goal.

In the following the mesh shading reflects mesh functions y=Sin[x] (the 1 was used to avoid difficulties with 0). Either one certainly would 'cut the sphere' in half (but any great circle could be chosen without the need for Sin[x]). In addition I plot Sin[x] on the x-y plane with corresponding pre-image of stereographic projection from {0,0,2} on the index sphere.

cp = With[{ms = {{Blue, Opacity[0.3]}, {Yellow, Opacity[0.3]}}}, 
   ContourPlot3D[
    x^2 + y^2 + (z - 1)^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, 0, 2},
    ContourStyle -> None, 
    MeshFunctions -> {#2 - Sin[#1] + 1 &, #2 + Sin[#1] + 1 &}, 
    Mesh -> {{1}, {1}}, MeshShading -> {ms, Reverse@ms}]];
spi[x_, y_] := {4 x, 4 y, 2 ( x^2 + y^2)}/(4 + x^2 + y^2);
anim[t_] := With[{
   s = {t, Sin[t], 0},
   tg = spi[t, Sin[t]],
   p1 = cp,
   pt = ParametricPlot3D[{u, Sin[u], 0}, {u, -Pi, Pi}], 
   plane = InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}], 
   sin = Table[spi[j, Sin[j]], {j, -100 Pi, 100 Pi, 0.1}]},
  Show[cp, pt, 
   Graphics3D[{Orange, Opacity[0.5], plane, Opacity[1], Black, Red, 
     Thick, Line[sin], Purple, PointSize[0.04], Point[s], Point[tg], 
     Gray, Thickness[0.005], Line[{{0, 0, 2}, s, tg}]}], 
   PlotRange -> {{-Pi, Pi}, {-1, 1}, {0, 2}}, Axes -> False, 
   Boxed -> False, Background -> Black, BoxRatios -> Automatic]]

The animated gif was created by exporting a sequence with t fron $-\pi$ to $\pi$:

enter image description here

ubpdqn
  • 60,617
  • 3
  • 59
  • 148
  • Yeah its exactly something like this! The only thing is my Sin is made in Plot3D so sphere is cut by one of the sinusoids hills. – Twardy Jun 08 '16 at 11:01
  • @Twardy I am still uncertain. I think it would be helpful if you show you approach (code) and where it breaks down or if you post even a handwritten example of a still frame of your planned animation. Good luck:) – ubpdqn Jun 08 '16 at 11:08
  • I have edited my post. You can look up =) And Thank you for your help =) – Twardy Jun 08 '16 at 11:29