As calculated, the overlap integrals represent the overlap of atomic orbitals that are aligned along the zaxis. In general, this will not be the case, and the diatomic overlap integral matrix must be rotated in order to represent the actual orientation used. The rotation operation can be constructed in a completely general way, or it can be constructed using trigonometric functions, as shown here.
The rotation matrices are well known, but the method by which they are constructed is by no means simple. Consider the general case of one atom at the origin, and a second atom at some point p(x,y,z). Let the angle from the second atom to the first atom to
the z z axis be b, and the angle of the projection of the second atom onto the xy plane to the y axis be a. Then, the porbital
transform is as shown in the following table:
Angular Dependence of the porbitals  
p(x)  p(y)  p(z)  
π+  cos a cos b  sin a  cos a sin b 
π  sin a cos b  cos a  sin a sin b 
σ  sin b  0  cos b 
Mathematical Tools for use with Spherical Harmonics 

When working with the angular components, it is normally easier to use the Cartesian symbols x, y, and z instead of the trigonometric forms. This avoids the potentially confusing expressions that involve the angles a, b, θ, and φ.
Consider the rotation of d(x^{2}y^{2}). The rotation components involved are: R(x) = (cosa.cosb)x + (sina.cosb)y + (sinb)z, and R(y) = (sina)x + (cosa)y .
Rd(x^{2}y^{2})>  =  (cos^{2}a.cos^{2}b)x^{2} + (2cosa.cosb.sina.cosb)xy + 
(sin^{2}a.cos^{2}b)y^{2} + (2sina.cosb.sinb)yz + (sin^{2}b)z^{2 }+  
(sin^{2}a)x^{2} + (2sina.cosa)xy + (cos^{2}a)y^{2} 
In this expression, the integral over all odd terms vanish, therefore:
<d(x^{2}y^{2})Rd(x^{2}y^{2})>  =  <x^{2}(cos^{2}a.cos^{2}b  sin^{2}a)x^{2}> +  
<x^{2}(sin^{2}a.cos^{2}b  cos^{2}a)y^{2}> +  
<x^{2}(sin^{2}b)z^{2}> +  
<y^{2}(cos^{2}a.cos^{2}b + sin^{2}a)x^{2}> +  
<y^{2}(sin^{2}a.cos^{2}b + cos^{2}a)y^{2}> +  
<y^{2}(sin^{2}b)z^{2}> 
cos^{2}a.cos^{2}b  sin^{2}a sin^{2}a.cos^{2}b + cos^{2}a
or(cos^{2}b + 1).(2cos^{2}a  1)
sin^{2}a.cos^{2}b  cos^{2}a + sin^{2}b  cos^{2}a.cos^{2}b + sin^{2}a  sin^{2}b
or(cos^{2}b + 1).(2cos^{2}a  1)
The rotation matrix element is thus:<d(x^{2}  y^{2})Rd(x^{2}  y^{2})> = <x^{4} 2x^{2}y^{2} +y^{4}>½(cos^{2}b + 1).(2cos^{2}a  1)
As a result of the fact that the angular components of the atomic orbitals are normalized, i.e., <x^{4 }^{ }2x^{2}y^{2 } +^{ }y^{4}>=1:<d(x^{2}  y^{2})Rd(x^{2}  y^{2})> = (2cos^{2}a  1)cos^{2}b + ½(2cos^{2}a  1)sin^{2}b
which is the form used in the calculation of the drotation matrix. The full set of dorbital rotation matrix elements is:
Angular Dependence of the dorbitals 


δ+ ≡ d(x^{2}  y^{2}) 
π+ ≡ d(xz) 
σ ≡ d(2z^{2}x^{2}y^{2}) 
π ≡ d(yz) 
δ ≡ d(xy) 
d(x^{2}y^{2}) 
(2cos^{2}a  1)cos^{2}b + ½(2cos^{2}a  1)sin^{2}b 
cosa.sinb.cosb 
√¾.sin^{2}b 
sina.sinb.cosb 
2.sina.cosa.cos^{2}b + sina.cosa.sin^{2}b 
d(xz) 
(2cos^{2}a  1)sinb.cosb 
cosa(2cos^{2}b  1) 
√3.sinb.cosb 
sina (2cos^{2}b  1) 
2.sina.cosa.sinb.cosb 
d(2z^{2}x^{2}y^{2}) 
√¾.(2cos^{2}a  1)sin^{2}b 
√3.cosa.sinb.cosb 
cos^{2}b  ½sin^{2}b 
√3.sina.sinb.cosb 
√3.sina.cosa.sin^{2}b 
d(yz) 
2sina.cosa.sinb 
sina.cosb 
0 
cosa.cosb 
(2cos^{2}a  1)sinb 
d(xy) 
2sina.cosa.cosb 
sina.sinb 
0 
cosa.sinb 
(2cos^{2}a  1)cosb 