def threefold(n, h, d, points=True): s = System(hextess(n, points)) ct = [] ct.append(PatternRangeConstraint(min=0, max=1.)) for p in 0, 4*np.pi/3, 2*np.pi/3: x = np.array([d/3**.5*np.cos(p), d/3**.5*np.sin(p), h]) r = euler_matrix(p, np.pi/2, np.pi/4, "rzyz")[:3, :3] for i in "x y z xy xz yz".split(): ct.append(PotentialObjective(derivative=i, x=x, rotation=r, value=0)) for i, v in ("xx", 1), ("yy", 1): ct.append(PotentialObjective(derivative=i, x=x, rotation=r, value=v)) s.rfs, c = s.optimize(ct) return s, c