Robotics arm project help! Scaling and converting analogRead?

Hi! I'm really new to Arduino and robotics.
I've been looking at code online, and am wondering why people convert form analogRead to voltage. I think this is what's going on in my project?

I've been dumped on a project where I'm trying to control a flexible robot arm with two segments. There are two joysticks, 8 stepper motors, an easy driver. I'm a bit confused with how its working...I added comments that give my thoughts, but please help me understand how this robot arm is being controlled!

If people can also give explanation to some of my comments in the other functions that'd also be extremely helpful

Below is the code for controlling one segment of the robot....

//VARIABLES, some are missing here but they're all in the code.
#define X1 A0      // Pin A0 connected to Joystick 1 x-axis
#define Y1 A1      // Pin A1 connected to Joystick 1 y-axis
#define button_1 38     // Pin 38 connected to Joystick Button 1

#define X2 A3      // Pin A2 connected to Joystick 2 x-axis
#define Y2 A2      // Pin A3 connected to Joystick 2 y-axis
#define button_2 39     // Pin 39 connected to Joystick Button 2


//rInput is analogRead from joysticks - 512 to center it
scale(double rInput)
{
  double scaled = 0.0
  if (rInput < -64.0 || rInput > 64.0 && abs(rInput) <= 512.0) //Not sure where 64 comes from!!!!
    scaled = rInput / 512.0; //Why do this?
  else if (rInput > 512.0) //when would this happen?
    scaled = 1;
  else if (rInput < -512.0) //when would this happen?
    scaled = -1;
}


//to set the speed and direction based on joystick position
double set(double position, int dir1, int dir2, int maxS)
{
  double speed;
  if (position < -0.05){  //WHY DO THIS?
    digitalWrite(dir_1, LOW); 
    digitalWrite(dir_2, HIGH); //X- or Y- on easy board
    forward = true; 
    speed = -position * 8; //why do negative position * 8??? Where does 8 come in?
  }
  else if (position >= -0.05 && position <= 0.05) 
    speed = 0;
  else if (position > 0.05){
    digitalWrite(dir_1, HIGH); //X+ or Y+ on easy board
    digitalWrite(dir_2, LOW);
    forward = false;
    speed = position * 8;
  }

  return speed;

}

void setBottomSpeed(double posX1, posY1) {

    speedX1 = set(posX1, dir1, dir2, maxS);  //dir pins connect to easy driver, are output pins
    forwardX1 = false;
    if (speedX1 == 0.0)
      nX1 = 0; //var for timing steps
    else
      nX1 = (int) (9 - ceil(speedX1)); //why 9?? why Do this at all? What does this mean?
    speedY1 = set(posY1, dir3, dir4, 8); //set speed and direction of joystick
    forwardY1 = true;
    if (speedY1 == 0.0)
      nY1 = 0; 
    else
      nY1 = (int) (9 - ceil(speedY1));

....
loop() {

    if(joysticks have been pressed)
        setbottomSpeed(scale(analogRead(X1) - 512.0), scale(analogRead(Y1) - 512.0));
        .....
}

am wondering why people convert form analogRead to voltage

Because the analogue to digital converter converts the voltage on its input pin to a count, varying from zero volts, to just under the analogue reference voltage.

AWOL:
Because the analogue to digital converter converts the voltage on its input pin to a count, varying from zero volts, to just under the analogue reference voltage.

Okay...in layman terms can you explain what this is for?? Sorry, I'm super new to this topic, but am trying to give myself a crash course.

analogRead produces a result of 0 to 1023. When the joystick is centred it will read 512 (roughly). For some reason whoever wrote that code decided it was easier to work with -512 to +512 rather than 0 - 1023 and also to convert what is intrinsically an integer into a double which takes more storage and slows the calculations right down.

The scale() function converts that to -1 to +1 (that's the divide by 512). But the last part of that uses a variable called "raw" which doesn't exist in the fragment you posted so I don't know where that comes from. I think the checks against 64 are just to give a dead zone so very small movements of the joystick around centre do nothing.

So nothing to do with converting to voltage. But why exactly it was written that way is anyone's guess.

Steve