On the formation of sand waves and sand banks: a unified theory