A method for determining the height of a plurality of spatial positions on a surface of a specimen, the method comprising the steps of: projecting a light beam on the surface, the light beam having a sinusoidal spatial pattern having a pattern wavelength in at least two directions perpendicular to an optical axis of the light beam; moving the spatial pattern to different spatial pattern positions, while scanning the surface along said optical axis in different scanning positions, wherein there is a fixed relationship between a moving distance between subsequent spatial pattern positions, and a scanning distance between subsequent scanning positions; wherein the spatial pattern is moved in a sequence of 2n steps (n > 2), each spatial pattern position having a different corresponding scanning position in a sequence of scanning positions, the spatial pattern being moved by n times repeating the following steps (a)-(c) involving a starting spatial pattern position, and a next spatial pattern position: (a) moving the spatial pattern relative to the starting spatial pattern position in a first spatial direction over a first moving distance of 1/4 pattern wavelength; (b) moving the spatial pattern relative to the starting spatial pattern position in a second spatial direction over a second moving distance of 1/n pattern wavelength to the next spatial pattern position; and (c) making this next position the starting spatial pattern position; detecting the light reflected by the surface in the scanning positions with the spatial pattern having corresponding spatial pattern positions; determining, from the detected light for each spatial position of the surface, an envelope curve of intensity values corresponding to scanning positions; and selecting a maximum of the envelope curve and its corresponding scanning position being representative of the height of the spatial position of the surface. projecting a light beam on the surface, the light beam having a sinusoidal spatial pattern having a pattern wavelength in at least two directions perpendicular to an optical axis of the light beam; moving the spatial pattern to different spatial pattern positions, while scanning the surface along said optical axis in different scanning positions, wherein there is a fixed relationship between a moving distance between subsequent spatial pattern positions, and a scanning distance between subsequent scanning positions; wherein the spatial pattern is moved in a sequence of 2n steps (n > 2), each spatial pattern position having a different corresponding scanning position in a sequence of scanning positions, the spatial pattern being moved by n times repeating the following steps (a)-(c) involving a starting spatial pattern position, and a next spatial pattern position: (a) moving the spatial pattern relative to the starting spatial pattern position in a first spatial direction over a first moving distance of 1/4 pattern wavelength; (b) moving the spatial pattern relative to the starting spatial pattern position in a second spatial direction over a second moving distance of 1/n pattern wavelength to the next spatial pattern position; and (c) making this next position the starting spatial pattern position; (a) moving the spatial pattern relative to the starting spatial pattern position in a first spatial direction over a first moving distance of 1/4 pattern wavelength; (b) moving the spatial pattern relative to the starting spatial pattern position in a second spatial direction over a second moving distance of 1/n pattern wavelength to the next spatial pattern position; and (c) making this next position the starting spatial pattern position; detecting the light reflected by the surface in the scanning positions with the spatial pattern having corresponding spatial pattern positions; determining, from the detected light for each spatial position of the surface, an envelope curve of intensity values corresponding to scanning positions; and selecting a maximum of the envelope curve and its corresponding scanning position being representative of the height of the spatial position of the surface.