Im looking at this gear curve: thinking wow I'd like to plot that! so then I tried, in c++, with gnuplot.
/*
the gear curve is a curve resembling a gear with n teeth given by the parametric equations
x = r*cos*t
y = r*sin*t,
where
r=a+1/b*tanh[b*sin(n*t)],
where tanhx is the hyperbolic tangent. Plots above show gear curves for a=1, b=10, and n=1 to 12. */
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main(){
ofstream plot;
plot.open("plotz.dat");
double r = 1;
int t = 0; //theta, might need to be an itterator.
double a = 1.1;
double b = 10;
double xx = r*cos(t);
double yy = r*sin(t);
//cout << "Sine 45: " << sin(45) << endl;
for(t=1;t <= 360; t+=1){
r = a+(1/b)*tanh(b*sin(12*t));
xx = r*cos(t);
yy = r*sin(t);
//cout << r << " " << xx << " " << yy << " " << endl;
plot << r << " " << xx << " " << yy << " " << endl;
}
plot.close();
return 0;
}
but instead of the nice smooth curve of the gear plot, I get something that is only vaguely similar.
I would like to get these sweet gear curves:

where did I go wrong? how can I get output that looks like that?