1. A method for three-dimensionally imaging a moving structure, comprising: recording a series of projection images by an image acquisition unit from different recording angles during a continuous rotation cycle with simultaneous recording an ECG; generating a three-dimensional reconstructed reference image of the moving structure from the projection images with an initial correction of a motion of the moving structure by affine transformations, wherein the three-dimensional reconstructed reference image is generated based on non-periodic motion of the moving structure; generating a motion-compensated three-dimensional reconstruction image data of the moving structure using the three-dimensional reconstructed reference image while performing an estimation and correction of the motion of the moving structure by elastic deformations, wherein the motion of the moving structure is estimated and corrected using the three-dimensional reconstructed reference image based on non-periodic motion of the moving structure, generating a set of time instants assigned to twelve affine motion parameters of an affine motion model that describe the affine transformations at the time instants; optimizing the estimation of the motion using the affine motion model; and generating a target function based on a relationship of the motion-compensated three-dimensional reconstruction image data with the recorded projection images, wherein the optimizing comprises: selecting the affine motion parameters; calculating a quality function; and optimizing the affine motion parameters, wherein the affine motion parameters are statistically selected, wherein the affine motion parameters are initially assigned with same probability, and wherein probabilities of the affine motion parameters in a following repetition are preselected so that the affine motion parameters of the non-periodic motion of the moving structure are selected during the optimization, and wherein the affine motion parameters of the non-periodic motion of the moving structure are selected in the following repetition if the affine motion parameters of the non-periodic motion of the moving structure obtain a greater gain in the target function.