Instead of using arctangent and exponential functions, why not just multiply the X axis by a factor of 4, clip it at 1, and normalize the resulting X,Y pair?
Code:
void adjust(float Xj, float Yj, float *Xa, float *Ya){
float mag;
*Ya=Yj;
if (Xj<=-0.25) *Xa=-1;
else if (Xj<0.25) *Xa=4.0*Xj;
else *Xa=1.0;
// normalize adjusted values:
mag=sqrt(*Xa**Xa+*Ya**Ya);
if (mag>1) {*Xa/=mag; *Ya/=mag;}
}
See attached Excel spreadsheet. The 100 tab shows an overview of adjusted XY pairs (cyan cells) for the entire first quadrant. The 25 tab zooms in for a closer look for small joystick values.
The attached plot shows a family of Xa vs Xj curves for Yj=0 to 1.
Or you could make the X gain a function of Yj, like so:
Code:
void adjust(float Xj, float Yj, float *Xa, float *Ya){
float mag, gain;
gain=1+3*Yj;
*Ya=Yj;
*Xa=gain*Xj;
if (*Xa>1) *Xa=1;
else if (*Xa<-1) *Xa=-1;
// normalize adjusted values:
mag=sqrt(*Xa**Xa+*Ya**Ya);
if (mag>1) {*Xa/=mag; *Ya/=mag;}
}
See attached plots for Xa vs Xj for Yj=0 to 1
and Ya vs Yj for Xj=0 to 1