  The results of an amplitude analysis of the charmless three-body decay $B^+
\rightarrow \pi^+\pi^+\pi^-$, in which $C\!P$-violation effects are taken into
account, are reported. The analysis is based on a data sample corresponding to
an integrated luminosity of $3 \text{fb}^{-1}$ of $pp$ collisions recorded with
the LHCb detector. The most challenging aspect of the analysis is the
description of the behaviour of the $\pi^+ \pi^-$ S-wave contribution, which is
achieved by using three complementary approaches based on the isobar model, the
K-matrix formalism, and a quasi-model-independent procedure. Additional
resonant contributions for all three methods are described using a common
isobar model, and include the $\rho(770)^0$, $\omega(782)$ and $\rho(1450)^0$
resonances in the $\pi^+\pi^-$ P-wave, the $f_2(1270)$ resonance in the
$\pi^+\pi^-$ D-wave, and the $\rho_3(1690)^0$ resonance in the $\pi^+\pi^-$
F-wave. Significant $C\!P$-violation effects are observed in both S- and
D-waves, as well as in the interference between the S- and P-waves. The results
from all three approaches agree and provide new insight into the dynamics and
the origin of $C\!P$-violation effects in $B^+ \rightarrow \pi^+\pi^+\pi^-$
decays.
