Confocal sensors for displacement, distance, position and thickness