Factor $f$ of internal energy of a gas For a $n$-atomic gas in any sort of geometry,
The formula for $f$ is
$$f = 3n- \text{number of constraints}.$$
The way I was taught this formula was like each $n$ particles< there is $3$ ways it can move so $3n$ now from these ways we need to exclude the number of constraints on it's motion. But now I'm confused, because couldn't the molecule move in any $x$, $y$ and $z$ direction like there are $6$ total directions because  for example there is  like $-x$ and $+x$ side. And for molecules with more than two particles, does the formula include rotational d.o.f as well? And, how do I know if I should include vibrational nodes or not?
I saw this question: Extra vibrational mode in linear molecule
But I'm looking for something more general to use like for any shape and kind of molecule. As in, I learned from chemistry that molecules can have different geometery according to vsepr theory based on lonepair and number of bonds
 A: The formula
$$
f = 3n - \textrm{# constrains}
$$
is valid for gas consisting of $n$ monoatomic particles. The fact that we use three degrees of freedom and not six can be memorised by the fact that the position vector (in 3D space) has three components: The number of degrees of freedom is equal to the number of coordinate components, which we need to specify the position of each atom.
If you have a diatomic gas, we have to include two rotational degrees of freedom (only rotation perpendicular to the line connecting the two atoms are observable), and one vibrational degrees of freedom. Depending on the temperature the vibrational degrees of freedom is "frozen". E.g. at room temperature we omit the vibrational degree of freedom. I believe it takes several hundreds degree Celsius to unfreeze the vibration (please cross-check).
Let's consider examples:

*

*$He$ (helium) is a monoatomic gas.

*$O_2$ (oxygen), and $N_2$ (nitrogen) are diatomic gases.

*$CO_2$ (carbon dioxide) is a triatomic gas.

The heat capacity of these gases differ, because the energy gets distributed among the degrees of freedom. Therefore, a monoatomic gas needs less energy to increase it's temperature by 1K then does a diatomic gas.
A: In the case of one point-like particle, one has only  3 independent configurational degrees of freedom because a position in 3D is uniquely identified by three independent displacements from a chosen origin.
The adjective independent is the key concept to exclude counting positive and negative displacements along an axis as two different degrees of freedom. The word independent, in the present context has exactly the same meaning as in the case of vector spaces: two displacements are independent if the only way to obtain a zero displacement by the linear combination
$$
a {\bf x} + b {\bf y}
$$
is when both $a$ and $b$ are zero.
If the particle is an m-atom  molecule, the configuration of each molecule requires $3m$ independent coordinates. However, if some distances can be treated as fixed, there is a reduction of the independent degrees of freedom, equal to the number of independent constraints.
For example, in the case of a rigid di-atomic molecule, we have $n=2$, but the resulting $6$ degrees of freedom are reduced to $5$ by the presence of a single scalar constraint on the distance between the two atoms. Which is consistent with the fact that one configuration is given once we provide three coordinates for the center of mass and two angles to assign the orientation of the molecule.
All rigid linear molecules have $5$ degrees of freedom: for each additional atom added to the first two, there are $3$ additional coordinates for its position, but 3 additional constraints originating from the rigid geometry (one distance plus two angles).
In the case of a non-linear molecule made by $3$ atoms, we have to subtract $3$ independent scala constraints of fixed distances from the $9$ degrees of freedom of a three-atom system. Here again, addition of more atoms with rigid distances from the first three, corresponds to add $3$ new coordinates but the same time $3$ more scalar constraints. As a result, a rigid non-linear molecule would require ony six numbers to uniquely identify its space configuration.
Of course, we could have more than 5 or 6 degrees of freedom, in the case of poly-atomic molecules, if only part of the distances are fixed.
So far, it's just matter of counting atoms and constraints. The real physical question is under  which conditions we could consider an intramoleclar distance as fixed? The answer requires Quantum Mechanics. It turns out that every motion requiring excitation $\Delta E \gg k_BT$ is dynamically frozen and the system behaves as if there would be a rigid constraint.
A: I don't like the formula you quote. At high temperatures a diatomic molecule has 7 degrees of freedom: 3 translational, 2 rotational, 2 vibrational. So according to your formula the number of constraints is –1 (minus 1). What is that supposed to mean?
Diatomic molecules have only two rotational degrees of freedom, corresponding to rotation about the 2 axes at right angles to the line joining the molecules. [It turns out that the energy levels for rotation about the latter axis (about which the molecule's moment of inertia is very small) are too far apart for much likelihood of energy storage at any temperature below that for which the molecule is likely to be in one piece!]
Diatomic molecules have two vibrational degrees of freedom, one for kinetic energy of vibration, the other for potential. Except for heavy molecules, such as chlorine, the energy levels are too far apart for significant energy above the zero point energy to be stored in these modes at room temperature. At high temperature these modes 'kick in'.
