Suppose $Oxyz$ is fixed in space. We specify one reference point in the rigid body using Cartesian coordinates in $Oxyz$. We use this point as the origin of the body-fixed frame $O'x'y'z'$. Consider the reference frame $O'xyz$, which has origin $O'$ (=reference point) and axes that are parallel to the axes of $Oxyz$.
Directional cosines can be used to set the relative orientation of two Cartesian frames with the same origin.
(Notation: Cartesian components are indicated with indices $i=1,2,3$ for $x,y,z$ respectively.)
The 9 directional cosines are ($i,j = 1,2,3$): $$ \cos\theta_{ij} = \vec{n}_i'\cdot \vec{n}_j,$$ with $\vec{n}$ the unit vector along the corresponding axes. The first index of $\theta_{ij}$ refers to the primed coordinate system.
Now my book states that directional cosines can be used to determine the components in one reference frame, when the components in another one (with the same origin) are given. Then without proof or clarifying picture, following relations are mentioned $$ \vec{n}_i = \sum_j (\vec{n}_i \cdot \vec{n}_j')\vec{n}_j' = \sum_j \cos\theta_{ji}\vec{n}_j'$$ and $$ \vec{n}_i' = \sum_j (\vec{n}_i' \cdot \vec{n}_j)\vec{n}_j = \sum_j \cos\theta_{ij}\vec{n}_j.$$
Could someone help me out with giving an intuition or - even better - a proof of why these last equations hold?