def get_angle(self, th_in, th_normal, rng, *args, **kwargs): if rng is None: rng = np.random th_rel = vector.normalise_angle(th_in - th_normal) antiparallels = np.isclose(np.abs(angle_dist(th_in, th_normal)), np.pi) signs = np.where(antiparallels, crandom.randbool(antiparallels.shape[0], rng), np.sign(th_rel)) th_rel = signs * np.pi / 2.0 return th_normal + th_rel
def tumble(self, tumblers, rng=None): if rng is None: rng = np.random self.sign[tumblers] = crandom.randbool(tumblers.sum(), rng=rng)