basexmin = -10;
basexmax = 0;
baseymin = -10;
baseymax  =  10;
  
refx = 1.0;
refy = 0.0;
basex = 0;
basey = 0;
  
linkLengths = {5, 5, 5};

degrees = {-45, 45, 
          45};
  
goal = {5, 5};

For[i = 1; radians = {}, 
        i <= Length[degrees], i++, 
radians = 
          Append[radians, degrees[[i]]*Pi/180]];

M = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
For[i = 1, 
      i ≤ 2, i++, 
M = 
        M . {
{Cos[
                radians[[i]]], -Sin[radians[[i]]], 
              0}, 
{Sin[radians[[i]]], 
              Cos[radians[[i]]], 0}, 
{0, 0, 
              1}
} . {{1, 0, linkLengths[[i]]}, {0, 1, 
              0}, {0, 0, 1}}; 
P = 
        M . {0, 0, 1};

]