A general model for moiré contouring. Part I: Theory