PeriodicWrap works by tiling the whole space by identical copies of single tile - the fundamental domain.
The interior of that tile is replicated. Parts of the shape
outside of fundamental domain are cropped.
The trick is to correctly place shapes to be replicated
inside of fundamental domain.
In the simplest one dimensional case illustrated below
Code:
var pw = new PeriodicWrap(new Vector3d(a,0,0));
the fundamental domain (yellow) is infinite slab orthogonal to the period vector
a.
Green circle is completely inside of fundamental domain and it perfectly replicated. Red circle is only partially inside. So, only it's part is replicated.
Important parameter of PeriodicWrap is its
origin. The code
Code:
pw.setOrigin(new Vector3d(x,y,z));
can be used to place the fundamental domain in convenient location. Default value of
origin is point (0,0,0).