confused on mapping a joystick to motor controller

i have an input shield and UNO.
sheild X/Y output 0-1024 to pins 4 and 5 on arduino.

My motor control accepts 0-255 for speed control plus forward or reverse

With my code below hacked from: http://home.kendra.com/mauser/Joystick.html
I can go forward backward and spin in one direction full speed.

My problem is spinning in the other direction on spins at half speed.

int joyPin1 = 4;                 // slider variable connecetd to analog pin 0
int joyPin2 = 5;                 // slider variable connecetd to analog pin 1
int coordX = 0;                  // variable to read the value from the analog pin 0
int coordY = 0;                  // variable to read the value from the analog pin 1
int centerX = 527;               // we measured the value for the center of the joystick
int centerY = 512;
int actualZone = 0;
int previousZone = 0;
void setup()
{
  Serial.begin(9600);
}
void loop() {
  // reads the value of the variable joystick 
  coordX = analogRead(joyPin1);   
  coordY = analogRead(joyPin2);   
  //maps from 0-1023 POT range to -100 - 100 range of formula
int coordXmapped = map(coordX,0,1023,-100,100);
int coordYmapped = map(coordY,0,1023,-100,100);
  // we print int the terminal 
  
  Serial.print("X Axis: ");  
  Serial.print(coordX);      //joystick X
  Serial.print("\n");
  Serial.print("Y axis: "); 
  Serial.print(coordY);     //joystick Y
  Serial.print("\n");
  
    Serial.print("X Axis Mapped: ");
  Serial.print(coordXmapped);  //joystick X mapped value
  Serial.print("\n");
  Serial.print("Y Axis Mapped: "); 
  Serial.print(coordYmapped);  //joystick Y mapped value
  Serial.print("\n");
  
  // invert the X coordinate to be used in the formula
  int coordXinvert = (coordXmapped*-1);  
  // the formulas 
  int v = ((100-abs(coordXinvert)) * (coordYmapped/100)+coordYmapped);
  int w = ((100-abs(coordYmapped)) * (coordXinvert/100) + coordXinvert);
  int rightwheel = ((v+w)/2);
  int leftwheel = ((v-w)/2);
  Serial.print("rightwheel: ");
  Serial.print(rightwheel);
  Serial.print("\n"); 
  Serial.print("leftwheel: ");
  Serial.print(leftwheel);
  Serial.print("\n");  
  
  //Now we have to use some trickery to setup the motor controller outputs
  int rightfrontback = 1;
  if(rightwheel<0)
  {
    rightfrontback = 0; 
  }
   int leftfrontback = 1;
  if(leftwheel<0)
  {
    leftfrontback = 0; 
  }
  
  int rightmotor = map(abs(rightwheel),0,100,0,255);
  int leftmotor = map(abs(leftwheel),0,100,0,255);
  
  Serial.print("rightwheel motor: ");
  Serial.print(rightmotor);
  Serial.print("\n"); 
  Serial.print("rightwheel motor direction: ");
   Serial.print(rightfrontback);
  Serial.print("\n");
  Serial.print("leftwheel motor: ");
  Serial.print(leftmotor);
  Serial.print("\n");
 Serial.print("leftwheel motor direction: ");
   Serial.print(leftfrontback);
  Serial.print("\n") ; 
 Serial.print("------------------------------------------") ;  
  Serial.print("\n") ; 
  delay (5000);

}

Heres a spin in one direction.
You can see it has both motors at full speed in different directions.

X Axis: 0
Y axis: 511
X Axis Mapped: -100
Y Axis Mapped: -1
rightwheel: 99
leftwheel: -100
rightwheel motor: 252
rightwheel motor direction: 1
leftwheel motor: 255
leftwheel motor direction: 0

But spinning in the other direction gets me:

X Axis: 1022
Y axis: 511
X Axis Mapped: 99
Y Axis Mapped: -1
rightwheel: -50
leftwheel: 49
rightwheel motor: 127
rightwheel motor direction: 0
leftwheel motor: 124
leftwheel motor direction: 1

as you can see only half speed to the motors.

any ideas?

i dont actually have the controller yet and am just "wireframing" my code to get started.
this is for tank style steering using a single joystick.

Have you tried looking at the values of v and w?

This is the way I do arcade drive (left and right are turn, forward and back are... uh... forward and back). It's just another way of doing it that makes more sense for me, and it might be helpful.

int joyY = analogRead(0)/4; // Get it 0-255
int joyX = analogRead(1)/4;
int leftmtr =  joyY - joyX;
int rightmtr = joyY + joyX;

int biggest = max(leftmtr, rightmtr);
if (biggest > 255) {
  // get both mtr values between 0 and 255
  leftmtr = (leftmtr * 255)/biggest;
  rightmtr = (rightmtr * 255)/biggest;
}
analogWrite(10, leftmtr);
analogWrite(11, rightmtr);

you know what also helps? Not mixing up X and Y. lol.

I tested your code but it wasnt quite doing it for me. So I dug back into mine and figured out I had swapped my pins.. bleh. Works great now.