Purpose: Detecting if two or multiple devices are moved together is an interesting problem for different applications. However, these devices may be aligned arbitrarily with regards to each other, and the three dimensions sampled by their respective local accelerometers can therefore not be directly compared. The typical approach is to ignore all angular components and only compare overall acceleration magnitudes — with the obvious disadvantage of discarding potentially useful information. Approach: In this paper, we contribute a method to analytically determine relative spatial alignment of two devices based on their acceleration time series. Our method uses quaternions to compute the optimal rotation with regards to minimizing the mean squared error. Practical implications: After derotaion, the reference system of one device can be (locally and independently) aligned with the other, and thus that all three dimensions can consequently be compared for more accurate classification. Findings: Based on real-world experimental data from smart phones and smart watches shaken together, we demonstrate the effectiveness of our method with a magnitude squared coherence metric, for which we show an improved EER of 0.16 (when using derotation) over an EER of 0.18 (when not using derotation). Originality: Without derotating time series, angular information cannot be used for deciding if devices have been moved together. To the best of our knowledge, this is the first analytic approach to find the optimal derotation of the coordinate systems, given only the two 3D time acceleration series of devices (supposedly) moved together. It can be used as the basis for further research on improved classification towards acceleration-based device pairing.