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 get_norm_angle(self, *args, **kwargs): return vector.normalise_angle(self.get_angle(*args, **kwargs))