I have a bar of length $L$, mass $m$, and negligible width. The bar can rotate along an axis through its center of mass (the rotation is in the $x$-$y$ plane), and also can move up and down (in the vertical axis).
My question is: What is the (gravitational) potential energy of this bar?
I've found several exercises where $PE=mgy_{CM}$, where $y_{CM}$ is the position of the bar's center of mass, though I don't know why the assumption of just taking the CM.
Since this is rigid body, I thought also in summing the potential energy of each particle (i.e, integrating the classical $mgy$ function with respect to the height $y$), but I don't know if this is correct, or necessary.