This article proposes an approach for optimizing the trajectory planning of quadrotors in structured environments, taking into consideration the trade-off between task execution time and energy consumption. The constraints taken into account are geometrical (boundary conditions in position and orientation, obstacle avoidance), kinematic (boundary conditions in velocity, linear velocity, and acceleration limits of the system), and dynamic (limit capacities in torque of the actuators, constraints related to the under-actuation of the system). The approach extends the Random Trajectory Profile Approach (RPA) to the case of quadrotors. The results of this approach are validated through experimental tests and compared with those in the literature, demonstrating its effectiveness in offline and online scenarios. The proposed approach offers a promising solution for achieving optimal trajectory planning of quadrotors in structured environments.