1. A method for forming a three-dimensional (3D) map of an object, comprising: illuminating the object from a light source so as to project a pattern onto the object; capturing an image of the pattern on the object using an array of detector elements; processing the captured image so as to measure respective offsets of elements of the pattern in the captured image relative to a reference pattern, the offsets comprising at least a first offset of a first element of the pattern and a second offset of a second element of the pattern, measured respectively in first and second, mutually-perpendicular directions in a plane of the array; computing a geometrical correction factor in response to the first offset; applying the geometrical correction factor to the second offset so as to find a corrected offset; and computing depth coordinates of the object in response to the corrected offset.