Group Abstract Group Abstract

Message Boards Message Boards

Create a circular/arc spring?

Posted 9 years ago

I'm trying to create a circular spring in Mathematica. That is, a spring that oscillates back and forth but along a circular arc, not along a 1D line. Most springs are written using ParametricPlot, but I cannot find a way for the spring to move in more than 1D with ParametricPlot. I have been able to draw a a spring along an arc using PolarPlot, but the problem is, is that it doesn't look like it's oscillating using Polar Plot. Is there some kind of function that is called PolarParametricPlot? One that utilizes both functionalities of each? Or does anyone know how to draw what I'm describing using one or the other?

I'm attaching some code that demonstrates where I'm stuck. One should be able to just click Evaluate Notebook, and the Graphics will show.

Attachments:
POSTED BY: Tim Kirkpatrick
7 Replies

I have modified the spring functions to oscillate in time, instead of manually adjusting the spring. The problem is that they do not compress and contract properly. Based on the oscillation functions defined, does anyone know how to use them so that the springs compress and contract along with the movement of the masses?

\[Theta]1[t_] = 
  1/72 (40 + E^(-I Sqrt[3/10] t) + E^(I Sqrt[3/10] t) + 
     3 E^(-((I t)/Sqrt[10])) + 3 E^((I t)/Sqrt[10])) \[Pi];

\[Theta]2[t_] = 
  1/72 (88 + E^(-I Sqrt[3/10] t) + E^(I Sqrt[3/10] t) - 
     3 E^(-((I t)/Sqrt[10])) - 3 E^((I t)/Sqrt[10])) \[Pi];

\[Theta]3[t_] = 
  1/36 (68 - E^(-I Sqrt[3/10] t) - E^(I Sqrt[3/10] t)) \[Pi];

Manipulate[
 Show[
  PolarPlot[
   {
    (1 + 0.2*
       TriangleWave[(3*x)/
         2*( \[Theta]2[time] - \[Theta]1[time] - \[Theta]3[time] ) ])
    },
   {x, \[Theta]2[time], \[Theta]1[time]},
   AspectRatio -> Automatic,
   Axes -> None,
   PlotRange -> {  -1.2*1, 1.2*1  },
   PerformanceGoal -> "Quality",
   ImageSize -> Medium
   ],
  PolarPlot[
   {
    (1 + 0.2*
       TriangleWave[(3*x)/
         2*(\[Theta]2[time] - \[Theta]1[time] - \[Theta]3[time])])
    },
   {x, \[Theta]2[time], \[Theta]3[time]},
   AspectRatio -> Automatic,
   Axes -> None,
   PlotRange -> {  -1.2*1, 1.2*1  },
   PerformanceGoal -> "Quality",
   ImageSize -> Medium
   ],
  PolarPlot[
   {
    (1 + 0.2*
       TriangleWave[(3*x)/
         2*(\[Theta]2[time] - \[Theta]1[time] - \[Theta]3[time] )])
    },
   {x, \[Theta]1[time], \[Theta]3[time] - 2 \[Pi]},
   AspectRatio -> Automatic,
   Axes -> None,
   PlotRange -> {  -1.2*1, 1.2*1  },
   PerformanceGoal -> "Quality",
   ImageSize -> Medium
   ],

  Graphics[{
    {(* Mass-1 *)
     Directive[  RGBColor[0, 0, 1], Opacity[0.75]  ],
     Disk[
      {
       1*Cos[  \[Theta]1[time]  ],
       1*Sin[  \[Theta]1[time]  ]
       },
      1/15
      ]
     (* Mass-1 *)},
    {(* Mass-2 *)
     Directive[  RGBColor[0, 0, 1], Opacity[0.75]  ],
     Disk[
      {
       1*Cos[  \[Theta]2[time]  ],
       1*Sin[  \[Theta]2[time]  ]
       },
      1/15
      ]
     (* Mass-2 *)},
    {(* Mass-3 *)
     Directive[  RGBColor[0, 0, 1], Opacity[0.75]  ],
     Disk[
      {
       1*Cos[  \[Theta]3[time]  ],
       1*Sin[  \[Theta]3[time]  ]
       },
      1/15
      ]
     (* Mass-3 *)}
    }]
  ],

 {
  {time, 1 E - 20},
  1 E - 20,
  120,
  ControlType -> Trigger,
  DefaultDuration -> 120.0,
  DisplayAllSteps -> True,
  AnimationRate -> 2.0
  },
 TrackedSymbols :> {time}
 ]
POSTED BY: Tim Kirkpatrick

I have found that the key is in the argument of the wave function. I have modified the script that Henrik provided to use the TriangleWave function. I'm not even certain I understand how dividing by the "time" parameter in the argument of the wave is able to create the wave-like feature (without it, an arc is created, not a wave), but it seems to work perfectly. See below:

Manipulate[

 ParametricPlot[
  {
   (1 + 0.2*TriangleWave[(20*t)/time])*Cos[t],
   (1 + 0.2*TriangleWave[(20*t)/time])*Sin[t]
   },
  {t, 0, time},
  AspectRatio -> Automatic,
  Axes -> None,
  PlotRange -> {  -1.2*1, 1.2*1  },
  PerformanceGoal -> "Quality",
  ImageSize -> Medium
  ],

 {
  {time, 0.1},
  0.1,
  2 Pi
  },
 TrackedSymbols :> {time}
 ]
POSTED BY: Tim Kirkpatrick

Hi Tim,

is it this you are having in mind(?):

sp[a_, t_] := {(r0 + r1 Cos[a t]) Cos[t], (r0 + r1 Cos[a t]) Sin[t], r1 Sin[a t]};

{r0, r1} = {1, .4};
Manipulate[ParametricPlot3D[sp[200/tt, t], {t, 0, tt}, AspectRatio -> Automatic,
   Boxed -> False, Axes -> None, PlotRange -> {-r0 - r1, r0 + r1}, 
  PerformanceGoal -> "Quality"], {{tt, Pi}, 1, 2 Pi}]

Regards -- Henrik

POSTED BY: Henrik Schachner
POSTED BY: Tim Kirkpatrick

If you strip the 3rd dimension from Henrik's example you get:

sp[a_, t_] := {(r0 + r1 Cos[a t]) Cos[t], (r0 + r1 Cos[a t]) Sin[t]};

{r0, r1} = {1, .4};
Manipulate[
 ParametricPlot[sp[200/tt, t], {t, 0, tt}, AspectRatio -> Automatic, 
  Axes -> None, PlotRange -> {-r0 - r1, r0 + r1}, 
  PerformanceGoal -> "Quality"], {{tt, Pi}, 1, 2 Pi}]
POSTED BY: Sander Huisman

Yes, I perfectly agree - I could not have found better words!

POSTED BY: Henrik Schachner

I agree; that solution works. I had tunnel vision focusing on using the TriangleWave function to define the spring. I am not certain the the TriangleWave function is robust enough to handle 2D oscillation though, so defining the spring as above is a good solution. Thanks!

POSTED BY: Tim Kirkpatrick
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard