Observations are reported of different sources of CP violation from an amplitude analysis of B+→π+π+π− decays, based on a data sample corresponding to an integrated luminosity of 3fb−1 of pp collisions recorded with the LHCb detector. A large CP asymmetry is observed in the decay amplitude involving the tensor f2(1270) resonance, and in addition significant CP violation is found in the π+π− S-wave at low invariant mass. The presence of CP violation related to interference between the π+π− S-wave and the P-wave B+→ρ(770)0π+ amplitude is also established; this causes large local asymmetries but cancels when integrated over the phase space of the decay. The results provide both qualitative and quantitative new insights into CP-violation effects in hadronic B decays.