Optimum synthesis of spatial function generator mechanisms