Detecting if two or multiple devices are moved together isan interesting problem for different applications. However,these devices may be aligned arbitrarily with regards to eachother, and the three dimensions sampled by their respectivelocal accelerometers can therefore not be directly compared.The typical approach is to ignore all angular componentsand only compare overall acceleration magnitudes – withthe obvious disadvantage of discarding potentially useful information. In this paper, we contribute a method to ana-lytically determine relative spatial alignment of two devicesbased on their acceleration time series. Our method usesquaternions to compute the optimal rotation with regards tominimizing the mean squared error. The implication is thatthe reference system of one device can be (locally and independently) aligned with the other, and thus that all threedimensions can consequently be compared for more accurate classification. Based on real-world experimental datafrom smart phones and smart watches shaken together, wedemonstrate the effectiveness of our method with a magnitude squared coherence metric, for which we show an im-proved EER of 0.16 (when using derotation) over an EERof 0.18 (when not using derotation).