parameters: (self,
                        axis,
                        angle_in_degrees,
                        node_indices='all',
                        adjust_displacement_field='auto')
docstring: Rotate nodes about an axis by the given angle.
docstring_summary: Rotate nodes about an axis by the given angle.
docstring_tokens: Rotate nodes about an axis by the given angle .
function: def _rotate_nodes(self,
                        axis,
                        angle_in_degrees,
                        node_indices='all',
                        adjust_displacement_field='auto'):
          """Rotate nodes about an axis by the given angle."""
          if adjust_displacement_field == 'auto':
              adjust_displacement_field = self.displacement_field_exists()
          # Create rotation matrix.
          # x --> R * x
          scale = math.sqrt(sum(x * x for x in axis))
          (ux, uy, uz) = [float(x) / scale for x in axis]
          theta = float(angle_in_degrees) * math.pi / 180
          cost = math.cos(theta)
          sint = math.sin(theta)
          # if angle_in_degrees is a multiple of 90 degrees, then make sin and
          # cos exactly 0, 1, or -1 to avoid roundoff errors.
          if angle_in_degrees % 90 == 0:
              sint = math.floor(sint + 0.5)
              cost = math.floor(cost + 0.5)
          rxx = cost + ux * ux * (1 - cost)
          rxy = ux * uy * (1 - cost) - uz * sint
          rxz = ux * uz * (1 - cost) + uy * sint
          ryx = uy * ux * (1 - cost) + uz * sint
          ryy = cost + uy * uy * (1 - cost)
          ryz = uy * uz * (1 - cost) - ux * sint
          rzx = uz * ux * (1 - cost) - uy * sint
          rzy = uz * uy * (1 - cost) + ux * sint
          rzz = cost + uz * uz * (1 - cost)
          # Rotate nodes.
          if node_indices == 'all':
              self.nodes = [[
                  rxx * x + rxy * y + rxz * z, ryx * x + ryy * y + ryz * z,
                  rzx * x + rzy * y + rzz * z
              ] for x, y, z in self.nodes]
          else:
              for index in node_indices:
                  n = self.nodes[index]
                  self.nodes[index] = [
                      rxx * n[0] + rxy * n[1] + rxz * n[2],
                      ryx * n[0] + ryy * n[1] + ryz * n[2],
                      rzx * n[0] + rzy * n[1] + rzz * n[2]
                  ]
          # Rotate the displacement field.
          if adjust_displacement_field:
              (disp_x, disp_y, disp_z) = self._get_displacement_field_values()
              for timestep_index in range(len(self.timesteps)):
                  if node_indices == 'all':
                      new_disp_x = [
                          rxx * x + rxy * y + rxz * z for x, y, z in zip(
                              disp_x[timestep_index], disp_y[timestep_index],
                              disp_z[timestep_index])
                      ]
                      new_disp_y = [
                          ryx * x + ryy * y + ryz * z for x, y, z in zip(
                              disp_x[timestep_index], disp_y[timestep_index],
                              disp_z[timestep_index])
                      ]
                      new_disp_z = [
                          rzx * x + rzy * y + rzz * z for x, y, z in zip(
                              disp_x[timestep_index], disp_y[timestep_index],
                              disp_z[timestep_index])
                      ]
                      disp_x[timestep_index] = new_disp_x
                      disp_y[timestep_index] = new_disp_y
                      disp_z[timestep_index] = new_disp_z
                  else:
                      for index in node_indices:
                          x = disp_x[timestep_index][index]
                          y = disp_y[timestep_index][index]
                          z = disp_z[timestep_index][index]
                          (x, y, z) = [
                              rxx * x + rxy * y + rxz * z,
                              ryx * x + ryy * y + ryz * z,
                              rzx * x + rzy * y + rzz * z
                          ]
                          disp_x[timestep_index][index] = x
                          disp_y[timestep_index][index] = y
                          disp_z[timestep_index][index] = z
function_tokens: def _rotate_nodes ( self , axis , angle_in_degrees , node_indices = 'all' , adjust_displacement_field = 'auto' ) : if adjust_displacement_field == 'auto' : adjust_displacement_field = self . displacement_field_exists ( ) # Create rotation matrix. # x --> R * x scale = math . sqrt ( sum ( x * x for x in axis ) ) ( ux , uy , uz ) = [ float ( x ) / scale for x in axis ] theta = float ( angle_in_degrees ) * math . pi / 180 cost = math . cos ( theta ) sint = math . sin ( theta ) # if angle_in_degrees is a multiple of 90 degrees, then make sin and # cos exactly 0, 1, or -1 to avoid roundoff errors. if angle_in_degrees % 90 == 0 : sint = math . floor ( sint + 0.5 ) cost = math . floor ( cost + 0.5 ) rxx = cost + ux * ux * ( 1 - cost ) rxy = ux * uy * ( 1 - cost ) - uz * sint rxz = ux * uz * ( 1 - cost ) + uy * sint ryx = uy * ux * ( 1 - cost ) + uz * sint ryy = cost + uy * uy * ( 1 - cost ) ryz = uy * uz * ( 1 - cost ) - ux * sint rzx = uz * ux * ( 1 - cost ) - uy * sint rzy = uz * uy * ( 1 - cost ) + ux * sint rzz = cost + uz * uz * ( 1 - cost ) # Rotate nodes. if node_indices == 'all' : self . nodes = [ [ rxx * x + rxy * y + rxz * z , ryx * x + ryy * y + ryz * z , rzx * x + rzy * y + rzz * z ] for x , y , z in self . nodes ] else : for index in node_indices : n = self . nodes [ index ] self . nodes [ index ] = [ rxx * n [ 0 ] + rxy * n [ 1 ] + rxz * n [ 2 ] , ryx * n [ 0 ] + ryy * n [ 1 ] + ryz * n [ 2 ] , rzx * n [ 0 ] + rzy * n [ 1 ] + rzz * n [ 2 ] ] # Rotate the displacement field. if adjust_displacement_field : ( disp_x , disp_y , disp_z ) = self . _get_displacement_field_values ( ) for timestep_index in range ( len ( self . timesteps ) ) : if node_indices == 'all' : new_disp_x = [ rxx * x + rxy * y + rxz * z for x , y , z in zip ( disp_x [ timestep_index ] , disp_y [ timestep_index ] , disp_z [ timestep_index ] ) ] new_disp_y = [ ryx * x + ryy * y + ryz * z for x , y , z in zip ( disp_x [ timestep_index ] , disp_y [ timestep_index ] , disp_z [ timestep_index ] ) ] new_disp_z = [ rzx * x + rzy * y + rzz * z for x , y , z in zip ( disp_x [ timestep_index ] , disp_y [ timestep_index ] , disp_z [ timestep_index ] ) ] disp_x [ timestep_index ] = new_disp_x disp_y [ timestep_index ] = new_disp_y disp_z [ timestep_index ] = new_disp_z else : for index in node_indices : x = disp_x [ timestep_index ] [ index ] y = disp_y [ timestep_index ] [ index ] z = disp_z [ timestep_index ] [ index ] ( x , y , z ) = [ rxx * x + rxy * y + rxz * z , ryx * x + ryy * y + ryz * z , rzx * x + rzy * y + rzz * z ] disp_x [ timestep_index ] [ index ] = x disp_y [ timestep_index ] [ index ] = y disp_z [ timestep_index ] [ index ] = z