8
$\begingroup$

I am looking for the code to generate a 3D graphic with this area rotated around its PQ-axis:

enter image description here

The red circle represents a silo centered at point P. A goat is tethered at point Q on the edge of the silo, with a tether length less than half the circumference of the silo, so that the area the goat is able to roam over is smaller than a circle.

I want to generate a 3D version of this figure, where the 2D figure above is rotated around the PQ axis. The result should look similar to (but distinctly different from) this

enter image description here

This example is just two simple spheres, not the more complicated figure I'm looking for.

$\endgroup$
6
  • 1
    $\begingroup$ Hi, welcome to MMA.SE. Take your equations and read documentation of ParametricPlot3D or SphericalPlot3D. You are going to be interested in Opacity too. $\endgroup$
    – Kuba
    Apr 11 '16 at 7:35
  • 1
    $\begingroup$ Obviously I read this and have no clue, that's why i am asking here. $\endgroup$
    – Martin
    Apr 11 '16 at 7:39
  • 5
    $\begingroup$ This is "obvious" only for you because we only see two links in your question. $\endgroup$
    – Kuba
    Apr 11 '16 at 7:48
  • $\begingroup$ See Goat Problem, Sphere-Sphere Intersection $\endgroup$
    – user9660
    Apr 11 '16 at 8:02
  • 3
    $\begingroup$ I wonder why people are setting this question "on hold" today as "unclear", after it was perfectly answered by Jason yesterday. $\endgroup$
    – Martin
    Apr 12 '16 at 14:08
24
$\begingroup$

What you need to do here is to generate a ParametricPlot to give the 2D goat/silo problem, and then we can rotate it with RevolutionPlot3D. From reading the page on MathWorld, we can see that we need to make a circle involute to describe the portion of the area where the goat's circle is limited by the presence of the silo. In Cartesian coordinates, this is written

$$ x = r \left( \cos \theta + \theta\sin \theta \right) $$

$$y = r \left( \sin \theta - \theta\cos \theta \right) $$

where $r$ is the radius of the silo and $\theta$ is the angle of rotation. At the point where $\theta=l/r$, where $l$ is the length of the rope, the goat can then move in an area described by a simple half circle. So we will run a ParametricPlot as a function of t where t can go from 0 to l/r, and we'll go ahead and set r=0 for simplicity.

First we need the silo,

With[{lr = π},
 ParametricPlot[{
   {Cos[2 π t/lr], Sin[2 π t/lr]}
   }
  , {t, 0, lr}]
 ]

enter image description here

Next we bring in the circle involute,

With[{lr = 2},
 ParametricPlot[{
   {Cos[2 π t/lr], Sin[2 π t/lr]},
   {Cos[t] + t Sin[t], Sin[t] - t Cos[t]}
   }
  , {t, 0, lr}]
 ]

enter image description here

Now for the portion of the goat's area where it is unimpeded by the silo. This is a half circle with radius l centered at the point {Cos[l], Sin[l]} with an initial angle of l,

With[{lr = 2},
 ParametricPlot[{
   {Cos[2 π t/lr], Sin[2 π t/lr]},
   {Cos[t] + t Sin[t], 
    Sin[t] - t Cos[t]}, {Cos[lr] + 
     lr Sin[lr + (π t)/lr], -lr Cos[lr + (π t)/lr] + Sin[lr]}
   }
  , {t, 0, lr}]
 ]

enter image description here

Finally, to get the last part of the circle, I'll use ReflectionTransform

With[{lr = 2},
 ParametricPlot[{
   {Cos[2 π t/lr], Sin[2 π t/lr]},
   {Cos[t] + t Sin[t], 
    Sin[t] - t Cos[t]}, {Cos[lr] + 
     lr Sin[lr + (π t)/lr], -lr Cos[lr + (π t)/lr] + 
     Sin[lr]},
   ReflectionTransform[{-Sin[lr], Cos[lr]}][{Cos[t] + t Sin[t], 
     Sin[t] - t Cos[t]}]
   }
  , {t, 0, lr}]
 ]

enter image description here

The next step is to rotate everything so that the tethering point stays fixed, and add a Point to show that location, then use Manipulate to show the effets of the tether size,

Manipulate[
 Module[{silo, circinv1, circinv2, tether, t},
  silo = {Cos[2 π t/l], Sin[2 π t/l]};
  circinv1 = {Cos[t] + t Sin[t], Sin[t] - t Cos[t]};
  circinv2 = ReflectionMatrix[{-Sin[l], Cos[l]}].circinv1;
  tether = {-1 - l Sin[(π t)/l], l Cos[(π t)/l]};
  {circinv1, circinv2} = 
   RotationTransform[π - l] /@ {circinv1, circinv2};
   ParametricPlot[{
    silo,
    tether,
    circinv1,
    circinv2
    },
      {t, 0, l},
   PlotStyle -> {Red, Blue, Blue, Blue},
   Epilog -> {PointSize -> Large, Point[{{-1, 0}}]},
   PlotRange -> {{-4.5, 2}, {-3.5, 3.5}}]]
  , {{l, .1}, .1, π, .01}]

enter image description here

To turn this into a 3D plot, we will use RevolutionPlot3D

With[{lr = .5 π},
 RevolutionPlot3D[{
   {Cos[2 π t/lr], Sin[2 π t/lr], 0},
   {Cos[t] + t Sin[t], Sin[t] - t Cos[t], 
    0}, {Cos[lr] + 
     lr Sin[lr + (π t)/(2 lr)], -lr Cos[lr + (π t)/(2 lr)] + 
     Sin[lr], 0}
   }
  , {t, 0, lr}, {θ, 0, 2 π},
  RevolutionAxis -> {Cos[lr], Sin[lr], 0}, 

  PlotRange -> All,
  Boxed -> False,
  Axes -> False]
 ]

enter image description here

Here is an animation for the 3D graphic,

Manipulate[
 silo = {Cos[2 π t/l], Sin[2 π t/l]};
 circinv1 = 
  RotationMatrix[π - l].{Cos[t] + t Sin[t], Sin[t] - t Cos[t]};
 tether = {-1 - l Sin[(π t)/(2 l)], l Cos[(π t)/(2 l)]};
 {silo, tether, circinv1} = Join[#, {0}] & /@ {silo, tether, circinv1};
 RevolutionPlot3D[Evaluate@{
    silo,
    tether,
    circinv1
    },
     {t, 0, l}, {θ, 0, 2 π},
  RevolutionAxis -> {1, 0, 0},
  PlotStyle -> {{Red}, {Opacity[0.5], Blue}, {Opacity[0.5], Blue}},
  PlotRange -> {{-4.5, 2}, {-3.5, 3.5}, {-3.5, 3.5}},
  Boxed -> False, Axes -> False] , {{l, .1}, .1, π, .05}]

enter image description here

Area (and volume) available for the goat (space goat?) to graze in

Most instances I find online talking about this problem use it as an example for integral calculus - finding the area available for grazing. You can find the explicit formula for the 2D problem by rewriting the parametric equations to explicitly depend on l and a (the tether length and the silo radius):

{circinv, tether, silo} = {{a (-Cos[l/a - t] + t Sin[l/a - t]), 
    a (t Cos[l/a - t] + Sin[l/a - t])}, 
    {-a - l Sin[(a π t)/(2 l)], l Cos[(a π t)/(2 l)]}, 
    {-a Cos[l/a - t], a Sin[l/a - t]}};

ParametricPlot[Evaluate[{tether, circinv, silo} /. {a -> 4, l -> 2}],
 {t, 1/2, 0}, AspectRatio -> .6]

enter image description here

For the area, we find the area of the three regions, add together the circle involute and tether and subtract off the silo, then double it.

Integrate[#2 D[#1, t], {t, l/a, 0}] & @@@ {tether, circinv, silo}
Expand[2 (#1 + #2 - #3) & @@ %]
(* {(l^2 π)/4, (a l)/2 + l^3/(6 a) - 
  1/4 a^2 Sin[(2 l)/a], -(1/4) a (-2 l + a Sin[(2 l)/a])} *)

(* l^3/(3 a) + (l^2 π)/2 *)

Which matches the formula from MathWorld. The volume in the 3D case is likewise easily found:

Integrate[π #2^2 D[#1, t], {t, l/a, 0}] & @@@ {tether, circinv, 
  silo}
Expand[2 (#1 + #2 - #3) & @@ %] // FullSimplify
(* {(2 l^3 π)/3, 
 1/12 a π (-64 a^2 + 36 l^2 + 63 a^2 Cos[l/a] + a^2 Cos[(3 l)/a]),
  4/3 a^3 π (2 + Cos[l/a]) Sin[l/(2 a)]^4} *)
(* 2/3 π (-18 a^3 + 9 a l^2 + 2 l^3 + 18 a^3 Cos[l/a]) *)

$$\frac{2}{3} \pi \left(18 a^3 \cos \left(\frac{l}{a}\right)-18 a^3+9 a l^2+2 l^3\right)$$

But I haven't seen this anywhere else to check my work :-)

$\endgroup$
1
  • $\begingroup$ I wonder what happens to your 2D formula if l > a pi $\endgroup$
    – Martin
    Apr 14 '16 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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