Carbon-nanotube geometries as optimal configurations