# Problem with ParametricPlot

I'm plotting gear curves, and I observe that for some parameter values ParametricPlot[] does not plot all the teeth:

gearCurve[a_, b_, n_] := ParametricPlot[
{
(a + 1/b Tanh[b Sin[n t]]) Cos[t],
(a + 1/b Tanh[b Sin[n t]]) Sin[t]
},
{t, 0, 2 Pi},
Axes -> False];
gearCurve[10, 5, 38]


produces the following image: What is going on?

Among several good illustrations the answer includes this undocumented option:

Method -> {Refinement -> {ControlValue -> (*radians*) }}


Alexey Popkov also gave an excellent analysis of the Plot algorithm.

His answer includes the apparently equivalent but cleaner (in degrees rather than radians as above):

Method-> {MaxBend -> (*degrees*) }


Example:

gearCurve[a_, b_, n_] :=
ParametricPlot[
{(a + 1/b Tanh[b Sin[n t]]) Cos[t],
(a + 1/b Tanh[b Sin[n t]]) Sin[t]},
{t, 0, 2 Pi},
Axes -> False,
Method-> {MaxBend -> 1}
];

gearCurve[10, 5, 38] • Note: Method -> {Refinement -> {ControlValue -> (*value*) }} was the option known as MaxBend in older versions of Mathematica. Jul 19, 2012 at 6:55
• @J.M. any idea why that option is no longer explicitly supported? Jul 19, 2012 at 7:04
• I don't, sorry. I'd like to know the answer to that question too... Jul 19, 2012 at 7:08
• @J. M., @Mr.Wizard The MaxBend option is still supported via Method -> {MaxBend -> maxBend} (where maxBend is in Degrees), see the "Edit 4" part here for more information. Jul 19, 2012 at 10:47
• @Alexey it's funny but I thought I remembered Yaroslav's answer being longer; I was remembering contents of your answer as being part of it. I'll add that to my answer! Jul 19, 2012 at 20:03

Sorry, the engineer inside couldn't resist Edit

Here is the code:

gearCurve[a_, b_, n_, c_, h_] :=
ParametricPlot[{c + (a + 1/b Tanh[b Sin[n t + h]]) Cos[t + h],
(a + 1/b Tanh[b Sin[n t + h]]) Sin[t + h]}, {t, 0, 2 Pi},
Axes -> False,
Method -> {Refinement -> {ControlValue -> 1 Degree}}];

Animate[Show[gearCurve[10, 5, 38, 0, h], gearCurve[10, 5, 38, 20, -h],
PlotRange -> {{-10, 30}, {-10, 10}}], {h, 0, 2 Pi, .01},
DisplayAllSteps -> True]

• Okay, now impress me. Jul 19, 2012 at 10:26
• @Mr.Wizard The Wankel thing at 2:03 is really beautiful Jul 19, 2012 at 10:30
• @Mr. Wizard, epicycloids/hypocycloids take a bit more work to do... :) Jul 19, 2012 at 10:52
• You don't need to animate the whole 360 when you have 38-fold rotational symmetry. Jul 19, 2012 at 22:19
• @wxffles In my machine there is something like a small jump when one animation finishes and the next is starting. That is the reason. Jul 19, 2012 at 22:28

Just need to bump up PlotPoints...

gearCurve[a_, b_, n_] :=
ParametricPlot[{(a + 1/b Tanh[b Sin[n t]]) Cos[
t], (a + 1/b Tanh[b Sin[n t]]) Sin[t]}, {t, 0, 2 Pi},
Axes -> False, PlotPoints -> 100];
gearCurve[10, 5, 38] • If you want to be able to adjust the PlotPoints or other options at will: gearCurve[a_, b_, n_, opts___] := ParametricPlot[{(a + 1/b Tanh[b Sin[n t]]) Cos[t], (a + 1/b Tanh[b Sin[n t]]) Sin[t]}, {t, 0, 2 Pi}, opts, Axes -> False, PlotPoints -> 100]. Better yet, the code is easily compacted: gearCurve[a_, b_, n_, opts___] := PolarPlot[a + 1/b Tanh[b Sin[n t]], {t, 0, 2 Pi}, opts, Axes -> False, PlotPoints -> 100] Jul 19, 2012 at 6:08