For particles in a system with periodic boundary conditions two particles can be neighbours even though they are on opposite sides of the system. This occurs often in molecular dynamics simulations, for example, in which clusters form at random locations and sometimes neighbouring atoms cross the periodic boundary. When a cluster straddles the periodic boundary, a naive calculation of the center of mass will be incorrect. A generalized method for calculating the center of mass for periodic systems is to treat each coordinate, x and y and/or z, as if it were on a circle instead of a line. The calculation takes every particle's x coordinate and maps it to an angle, θ θ i = x i x max 2 π π where x max is the system size in the x direction and x i ∈ ∈ [ 0 , x max ) . From this angle, two new points ( ξ ξ i , ζ ζ i ) can be generated, which can be weighted by the mass of the particle x i for the center of mass or given a value of 1 for the geometric center: ξ ξ i = cos ⁡ ⁡ ( θ θ i ) ζ ζ i = sin ⁡ ⁡ ( θ θ i )