elastic collision between square and walls, matlab