Analysis of grazing bifurcations of quasiperiodic system attractors