A molecule is a collection of moving positively-charged nuclei surrounded by a cloud of negatively-charged electrons that are held together by electrostatic force. The electrostatic interaction may create a strong and long-lasting attraction between particles that favors certain spatial configurations of nuclei, which we associate with molecular structure. In the isotropic space, the electrostatic interaction between the particles does not change if the system is rotated or translated in space as a whole. So, it makes sense to distinguish and separate a molecule's rotational and transnational motions from its 'internal' motions.
Coordinate frames and types of motion in molecule (red dot shows molecular center of mass)
Formally, to do this, we introduce three different Cartesian frames. The laboratory frame $(X,Y,Z)$ has its origin and orientation of axes that are not linked with the molecule, but rather with a specific experimental setup (e.g., the origin can be placed at the laser focus and axes are oriented depending on laser polarization, detector position, etc.). In the laboratory frame, the transnational motion of a molecule as a whole is described by a vector pointing to the molecule's center of mass (COM). The moving laboratory frame $(x,y,z)$ has its origin at the COM, so it moves with the molecule, and its axes are parallel to the laboratory frame's. The molecular frame $(a,b,c)$ is the frame that is attached to the molecule. It has its origin at the molecule's center of mass. For example, for the formaldehyde molecule (figure above), the $a$ axis is oriented along the C—O bond and the $b$ axis is perpendicular to the $a$ and lies in the plane formed by the two hydrogen (H) and one oxygen (O) nuclei. A set of rules, in a form of three equations, that tell us how to orient the molecular frame axes in a molecule at any instantaneous configuration are called the molecular frame embedding. The relative orientation of the molecular frame with respect to the moving laboratory frame describes the overall rotational motion of the molecule. The remaining 3 * <number of atoms> - 6 coordinates (6 = 3 for translations + 3 for rotations) describe the internal (vibrational) motions of particles (nuclei and electrons) relative to the molecular frame.
Mathematically, the relationship between the Cartesian coordinates of particles in the laboratory frame, $\mathbf{R}_{i} = (X_i, Y_i, Z_i)$ ($i$ = 1..<number of atoms>), and molecular frame, $\mathbf{r}_i = (a_i, b_i, c_i)$, can be expressed as
$$ \mathbf{R}{i} = \mathbf{R}\text{COM} + \mathbf{S}(\phi,\theta,\chi)\cdot\mathbf{r}{i}(q_1,q_2,...,q{3N-6}), $$
where $\mathbf{S}$ is a rotation matrix, that depends on three Euler angles $\phi,\theta,\chi$, and $q_1,q_2,...,q_{3N-6}$ are the internal (vibrational) coordinates (e.g, $r_1, r_2, r_3, \alpha_1,\alpha_2,\alpha_3$ coordinates in formaldehyde molecule on the figure above). The explicit expression for the rotation matrix can be found elsewhere, for example on Wolfram Mathworld.
https://mathworld.wolfram.com/EulerAngles.html
The coordinates of the center of mass can be found as
$$ \mathbf{R}\text{COM} = \left(\begin{array}{cc} X\text{COM} \\ Y_\text{COM} \\ Z_\text{COM} \end{array}\right) = \left(\begin{array}{cc} \sum_i x_im_i/\sum_i m_i \\ \sum_i y_im_i/\sum_i m_i \\ \sum_i z_im_i/\sum_i m_i \end{array}\right), $$
where $m_i$ is mass of $i$th nucleus.
In order to describe the molecular dynamics associated with different types of motions, the transformation described above need to be placed into the expression for kinetic energy:
$$ 2T = \sum_i m_i v_i^2 = \sum_i m_i \dot{\mathbf{R}}_i\cdot \dot{\mathbf{R}}_i. $$
The velocity $\dot{\mathbf{R}}_i$ is obtained by differentiating the expression for $\mathbf{R}_i$ with respect to time:
$$ \dot{\mathbf{R}}{i} = \dot{\mathbf{R}}\text{COM} + \dot{\mathbf{S}}(\phi,\theta,\chi)\cdot\mathbf{r}_{i}
$$
where $\boldsymbol{\omega} = (\omega_x, \omega_y,\omega_z)$ is the angular velocity vector (because tangent velocity due to angular motion is $v_i = \dot{r}_i = r_i\times \omega_i$, see Wiki: Angular velocity). The kinetic energy becomes:
$$ 2T = \sum_i m_i\left( \dot{\mathbf{R}}_\text{COM}^2
In this expression, the second term will disappear if the origin of molecular frame is placed at the center of mass, i.e.,
$$ 2\sum_i m_i\dot{\mathbf{R}}\text{COM}\cdot (\boldsymbol{\omega}\times\mathbf{r}i + \dot{\mathbf{r}}{i}) = 2\dot{\mathbf{R}}\text{COM}\cdot (\boldsymbol{\omega}\times \sum_i m_i \mathbf{r}i + \sum_i m_i \dot{\mathbf{r}}{i}) = 0, $$