(Major headache...!) - 1 line code crashes arduino

While you are fixing the oversize array, take a look at this statement:

int L = (int)sqrt(pow(X,2)+pow(Y,2));

and this page:
http://arduino.cc/en/Reference/Pow
The pow() function expects two floats, not two ints. So, a cast is performed to convert the ints to floats, so that pow can effectively do this for you: X * X.

Instead of the casts and the overhead of a relatively inefficient algorithm, just multiply the number by itself.

One last observation. Executable code must be in a function.

int w= 38*StepUnit;
int h= 28*StepUnit;

int x1= w/2;
int y1= h;

int a1= sqrt(pow(x1,2)+pow(y1,2));
int b1= sqrt(pow((w-x1),2)+pow(y1,2));

None of this code will do what you think it will.