In order to improve the ability of intelligent reasoning and prediction of 3DR27 model which presented in our previous work, enhance the usability of 3DR27 model, and better fulfill the demands of real applications for complex 3D spatial database, we focused on the problem of inversing 3D cardinal direction relations between spatial objects. In order to realize automated reasoning, an algorithm for computing the inverse of 3D cardinal direction relations based on matrices is proposed on the basis of the mapping between the 3D rectangular cardinal direction relations and 3D interval relation matrix. This algorithm improves the power of reasoning for this model by means of the excellent properties of matrix operations. Theorems are provided to prove formally that our algorithm is correct and complete. This study realized the automatic inference and calculation of the inverse of the 3D cardinal direction relations based on 3DR27 model and further improved the ability of spatial reasoning and spatial analysis of spatial database.