var vVelocity[3]; //Ball speed vector!
var vBounce[3]; //Bounce vectro that gets copied to vVelocity
var a;
//normal vectors of edges
var nvec_minx[3] = {1, 0, 0 };
var nvec_maxx[3] = {-1, 0, 0 };
//=======================================================
// b = 2*|<c,n>|*n + c Bounce vector's formula.
/*
a = 2*abs(vec_dot(c, n));
vec_set(c, vector(a*n[0], a*n[1],0));
vec_add(c, c);
*/
//nvec_maxx = vec_normalize(nvec_maxx,1);
a = 2*abs(vec_dot(vVelocity, nvec_maxx));
vec_set(vBounce, vector(a*nvec_maxx[0], a*nvec_maxx[1],0));
vec_add(vVelocity, vBounce);