def rotate_orbital(self, phi=0, theta=0, psi=0): old_axes = get_rotation_axes(*self.orientation[:2]) new_axes = get_rotation_axes(phi, theta) for item in chain(self.bonds, self.mesh): # Undo current orientation self._rotate_item(item, old_axes, *self.orientation, backward=True) # Actuallly rotate to new orientation self._rotate_item(item, new_axes, phi, theta, psi, backward=False) self.orientation = [phi, theta, psi]
def rotate_molecule(self, phi=0, theta=0, psi=0): # Rotate using Euler angles phi, theta, psi old_phi = self.phi old_theta = self.theta old_psi = self.psi # first rotate items back to original orientation axes = get_rotation_axes(old_phi, old_theta) for item in self.items: item.rotate(old_psi, axes[2][0], axes[2][1], axes[2][2], local=True) # first undo psi-rotation item.rotate(old_theta, axes[1][0], axes[1][1], axes[1][2], local=True) # next undo theta-rotation item.rotate(old_phi, axes[0][0], axes[0][1], axes[0][2], local=True) # finally undo phi-rotation # now rotate items to new desired orientation axes = get_rotation_axes(phi, theta) for item in self.items: item.rotate(-phi, axes[0][0], axes[0][1], axes[0][2], local=True) # first do phi-rotation item.rotate(-theta, axes[1][0], axes[1][1], axes[1][2], local=True) # next do theta-rotation item.rotate(-psi, axes[2][0], axes[2][1], axes[2][2], local=True) # finally do psi-rotation self.phi = phi self.theta = theta self.psi = psi return
def _refresh_mesh(self): if self.mesh is not None: self.removeItem(self.mesh) self.mesh = None if self.orbital is None: return data = self.orbital.psik['data'] self.mesh = self._get_iso_mesh(data) self.addItem(self.mesh) # Updating the mesh after iso val change would leave it # unrotated axes = get_rotation_axes(*self.orientation[:2]) self._rotate_item(self.mesh, axes, *self.orientation, backward=False)
def _refresh_mesh(self): if self.mesh: for mesh in self.mesh: self.removeItem(mesh) self.mesh = [] if self.orbital is None or not self.options.is_show_mesh(): return data = self.orbital.psi['data'] plus_mesh = self._get_iso_mesh(data, 'red', 1) minus_mesh = self._get_iso_mesh(data, 'blue', -1) self.addItem(plus_mesh) self.addItem(minus_mesh) self.mesh = [plus_mesh, minus_mesh] # Updating the mesh after iso val change would leave it # unrotated axes = get_rotation_axes(*self.orientation[:2]) for item in self.mesh: self._rotate_item(item, axes, *self.orientation, backward=False)