An algorithm is described which, starting with any geometrical figure, constructs a representation in which the deviations from the model coincide with the known perceptual distortions. First, the algorithm specifies a measurement process: drawing a straight line across the figure and measuring the encountered segments, assigning to every segment of length x its measure m(x). Next, the measures taken along a line D are corrected with a normalizing factor N(D) which is a function of the measures made on this line. Finally, a representation of the analysed figure is constructed, using for every segment its normalized length n(x) = m(x). N(D), instead of its actual length. It is first established that within this general framework, a large number of illusions can be immediately predicted by specifying a property of the measure or of the norm. Only four properties are required to justify most illusions. They are (1) and (2) m(x) and n(x) must be convex functions (3) the norm must increase with the number of segments measured on a line (4) the norm must decrease when the average segment on a line increases in length. It is then shown that the four requirements, conflicting as they may be in some circumstances, can nevertheless be condensed into one single expression of n(x). This simple formula predicts a large number of widely different illusions (Delboeuf, Titchener, Ponzo, trapeze, Müller-Lyer, flattening of short arcs, etc.). It permits to predict new illusions and new effects in old illusions, but fails to predict the Zöllner illusion, and the reversal of the Muller-Lyer illusion when the outgoing firms are becoming very large. © 1979.