The equality case in a Poincaré-Wirtinger type inequality