A professional point of view suggests that photovoltaic systems should be installed at the optimum tilt angle and orientation. However, in photovoltaic systems integrated in buildings the flexibility of installation is common. This paper is organized in two different parts. In the first one, the energy losses caused by deviations from the tilt angle (β) and the orientation (γ) of the installation in relation to the ideal position are evaluated. This work considers the cloudy-sky conditions in each locality and theoretically calculates by applying the Cavaleri’s principle, the energy losses. Ten cities around the world, in the northern hemisphere, have been studied with a MATLAB code and the findings demonstrate that non-ideal tilt and azimuth angles can also lead to acceptable levels of electric energy generation. A photovoltaic system installed in South orientation (γ=0°) and β deviations of up to 10 (°) in relation to the optimum tilt angle has a very small influence on the energy losses. The energy losses are: 5%, 10%, 15% and 20% when β deviations are respectively: 21–23 (°), 31–33 (°), 37–40 (°) and 43–47 (°). Then, in the second part, an important application of this previous outcome comes out: the best distribution of the photovoltaic modules on a flat roof of irregular shape of an urban building is achieved.The aim of this work is to maximize the amount of energy get by a photovoltaic system. This engineering problem is highly complex as it involves 10 variables: the available flat roof area, the shape and the orientation of the available flat roof area, the dimensions (length and width) of the commercial photovoltaic modules, the orientation and the position of the photovoltaic modules, the number of the photovoltaic modules, the minimum distances (maintenance operations, to avoid shadowing effects) between rows of photovoltaic modules, and the minimum distance to the terrace boundary. In this context, this work aims to present a study to assist the decision-making.This paper shows a packing algorithm (in Mathematica™) which maximizes the energy generation area of the solar photovoltaic system, considering shadings and distances required for maintenance. Eventually, using the initial study, it comes out the influence of β on the potential capacity of the solar photovoltaic system and it is demonstrated that a decrease in the optimal tilt angle results in an increase up to 24% in the amount of obtained energy keeping invariable the available area. For example, in Almeria, with an optimum tilt angle of 30.3 (°) the amount of obtained energy is 149.8 (MWh) while with a tilt angle of 14 (°) the amount of obtained energy is 186.2 (MWh). This analysis enables to find the optimal answer to the following practical questions: what number of photovoltaic modules is required?, which is the right position for the photovoltaic modules?, and what orientation of photovoltaic modules is the right one?. There are many installers of photovoltaic systems who would benefit from studies about this issue.