This thesis presents a study of the flavour-changing neutral-current radiative B+ to K+pi-pi+gamma decay performed using 3 fb-1 of data collected with the LHCb detector in proton-proton collisions at 7 and 8 TeV centre-of-mass energies. The study of radiative decays with three scalar hadrons in the final state gives access to the polarisation of the photon, one of the very few predictions of the Standard Model of particle physics that has not been precisely tested experimentally and that is sensitive to new physics effects in the b to s gamma penguin loop. Nearly 14 000 signal events, containing all possible intermediate resonances with a K+pi-pi+ final state in the [1,2] GeV/c2 mass interval, are reconstructed and selected in the data sample. The distribution of the angle of the photon direction with respect to the plane defined by the final-state hadrons in their rest frame is studied in intervals of K+pi-pi+ mass and the asymmetry between the number of signal events with the photon emitted on each side of the plane is obtained. The first direct observation of the photon polarisation in the b to s gamma transition is reported with a significance of 5.2 sigma. The contributions of the resonances populating the studied K+pi-pi+ mass interval are then disentangled by means of a three-dimensional amplitude analysis of the invariant squared masses of the K+pi-pi+, K+pi- and pi+pi- systems, integrating out the angular dimensions that describe the direction of the photon. The results of this analysis are the most precise ever obtained in this decay channel, allowing for an accurate description of the decay modes of the intermediate resonances and their interference patterns: the K1(1270)+ to K+rho(770)0 channel has been found to be the dominant kaon resonance decay mode, followed by K1(1270)+ to K*(892)0pi+; the fraction of the K1(1270)+ decaying to K*(1430)0pi+ has been found to be much lower than the world average, analogously to already existing experimental and theoretical studies; a significant interference between the K1(1270)+ and K1(1400)+ kaon resonances decay modes is observed. Based on the results of these studies, the full five-dimensional amplitude analysis of the invariant masses and the angular variables is introduced, aiming at the first determination of a numerical value for the polarisation of the photon.