def orients_one_unit(self, delta_deg): sym = EMAN2.parsesym(self._symtype) drad = np.pi * delta_deg / 180.0 # generate uniform orientations on the sphere vecs = np.float32(Symmetry.calc_points(drad)) nvec = vecs.shape[0] # convert unit vectors to azimuth and altitude az = 180.0 * np.arctan2(vecs[:, 0], vecs[:, 2]) / np.pi + 180.0 alt = 180.0 * np.arcsin(vecs[:, 1]) / np.pi + 90.0 # zero out azimuth on poles aloc = np.logical_or(alt == 0.0, alt == 180.0) az[aloc] = 0.0 # select orientations inside the asymmetric unit, including mirrors (True) isin = np.array([ sym.is_in_asym_unit(float(az[v]), float(alt[v]), True) for v in range(nvec) ]) azin = az[isin] altin = alt[isin] ors = [ EMAN2.Transform({ "type": "eman", "az": float(a), "alt": float(al), "phi": 0.0 }) for a, al in zip(azin, altin) ] return ors
def orients2mats_all_units(self, orients): ''' returns rotation matrices corresponding to orientations in each symmetric unit mats: nsym,nrots,3,3 ''' nrots = len(orients) nsym = EMAN2.parsesym(self._symtype).get_nsym() mats = np.zeros([nsym, nrots, 3, 3], dtype='float32') for n in range(nsym): for k in range(nrots): m = orients[k].get_sym(self._symtype, n).get_matrix() mats[n, k] = np.reshape(m, [3, 4])[..., :3] return mats