# Convert .car file PBC to basis vectors?

I have a .car file that contains dimensions (periodic boundary conditions) for the unit-cell of a hexagonal crystal material I'm working with:

PBC 27.1979 27.1979 15.4999 90.0000 90.0000 120.0000 (P1) 

That's the a, b, c lengths and $\alpha$, $\beta$, $\gamma$ angles.

I need to convert this information into basis vectors in cartesian space, e.g.

basis1 27.1979 ? 0.0 basis2 0.0 27.1979 0.0 basis3 0.0 0.0 15.4999

This may be better suited as a math question but it's computational-chemistry specific.

I found the way to convert the hexagonal parameters:

I have a,b,c and $\alpha$, $\beta$, $\gamma$. The solution in basis vectors is:

basis1 = (a, 0, 0)
basis2 = (xy, yx, 0)
basis3 = (xz, yz, c)


where \begin{align} xy &= b\cdot\cos(\gamma)\\ yx &= b\cdot\sin(\gamma)\\ xz &= c\cdot\cos(\beta)\\ yz &= \frac{b\cdot c\cdot \cos(\alpha) - xy \cdot xz}{\sqrt{b^2 - xy^2}}\\ \end{align}

Thus my solution was:

basis1 = (27.1979,  0,       0     )
basis2 = (-13.5990, 23.5541, 0     )
basis3 = (0,        0,       15.499)

• Since $\alpha=\beta=90^\circ$, you may simplify this a great deal. Your third vector is just $(0,0,c)$. – Ivan Neretin Jan 16 '17 at 21:41