The science of moire patterns