Self-similar and asymptotically self-similar solutions of nonlinear wave equations