def execute(self,obj,event):
    print self.timer_count
    self.textActor.SetInput('Time: %s' % self.timer_count)
    r_vectors = bm.get_boomerang_r_vectors_15(
      self.locations[self.n*TIME_SKIP], 
      Quaternion(self.orientations[self.n*TIME_SKIP]))

    for k in range(N_SPHERES):
      self.sources[k].SetCenter(r_vectors[k][0], r_vectors[k][1],
                                r_vectors[k][2])
    if DRAW_COH:
      coh = bm.calculate_boomerang_coh(
        self.locations[self.n*TIME_SKIP], 
        Quaternion(self.orientations[self.n*TIME_SKIP]))
      cod = bm.calculate_boomerang_cod(
        self.locations[self.n*TIME_SKIP], 
        Quaternion(self.orientations[self.n*TIME_SKIP]))
      self.coh_source.SetCenter(coh)
      self.cod_source.SetCenter(cod)

    iren = obj
    iren.GetRenderWindow().Render()
    if WRITE:
      self.w2if.Update()
      self.w2if.Modified()
      self.lwr.SetFileName(os.path.join(
          '.', 'figures',
          'frame'+ ('%03d' % self.n)+'.png'))
      self.lwr.Write()
    self.timer_count += 0.01*TIME_SKIP
    self.n += 1
コード例 #2
0
    def execute(self, obj, event):
        print self.timer_count
        self.textActor.SetInput('Time: %s' % self.timer_count)
        r_vectors = bm.get_boomerang_r_vectors_15(
            self.locations[self.n * TIME_SKIP],
            Quaternion(self.orientations[self.n * TIME_SKIP]))

        for k in range(N_SPHERES):
            self.sources[k].SetCenter(r_vectors[k][0], r_vectors[k][1],
                                      r_vectors[k][2])
        if DRAW_COH:
            coh = bm.calculate_boomerang_coh(
                self.locations[self.n * TIME_SKIP],
                Quaternion(self.orientations[self.n * TIME_SKIP]))
            cod = bm.calculate_boomerang_cod(
                self.locations[self.n * TIME_SKIP],
                Quaternion(self.orientations[self.n * TIME_SKIP]))
            self.coh_source.SetCenter(coh)
            self.cod_source.SetCenter(cod)

        iren = obj
        iren.GetRenderWindow().Render()
        if WRITE:
            self.w2if.Update()
            self.w2if.Modified()
            self.lwr.SetFileName(
                os.path.join('.', 'figures',
                             'frame' + ('%03d' % self.n) + '.png'))
            self.lwr.Write()
        self.timer_count += 0.01 * TIME_SKIP
        self.n += 1
コード例 #3
0
def calc_boomerang_experimental(location, orientation):
    ''' Function to get boomerang CoH from the chakrabarty paper,
  which is tracked as location. this is for the 15 blob boomerang.'''
    r_vectors = bm.get_boomerang_r_vectors_15(location, orientation)
    dist = 1.16
    experiment_pt = (location + np.cos(np.pi / 4.) * (dist / 2.1) *
                     (r_vectors[0] - location) + np.cos(np.pi / 4.) *
                     (dist / 2.1) * (r_vectors[14] - location))

    return experiment_pt
コード例 #4
0
def calc_boomerang_cod(location, orientation):
    ''' Function to get boomerang CoD, which is tracked as location.
  this is for the 15 blob boomerang.'''
    r_vectors = bm.get_boomerang_r_vectors_15(location, orientation)
    dist = 0.96087
    coh = (location + np.cos(np.pi / 4.) * (dist / 2.1) *
           (r_vectors[0] - location) + np.cos(np.pi / 4.) * (dist / 2.1) *
           (r_vectors[14] - location))

    return coh
コード例 #5
0
  eijk = np.zeros( (3, 3, 3) )
  eijk[0,1,2] = 1
  eijk[1,2,0] = 1
  eijk[2,0,1] = 1
  eijk[1,0,2] = -1
  eijk[0,2,1] = -1
  eijk[2,1,0] = -1

  # Define location and orientation
  location = [0., 0., 100000.]
  theta = np.random.normal(0., 1., 4)
  #orientation = Quaternion(theta/np.linalg.norm(theta))
  orientation = Quaternion([1., 0., 0., 0.])
  
  # Get blobs vectors
  r_vectors = bm.get_boomerang_r_vectors_15(location, orientation)

  # Compute mobility at the cross point
  mobility = bm.force_and_torque_boomerang_mobility(r_vectors, location)
           
  # Get sub-matrix M^wF
  mobility_wF = mobility[3:6, 0:3]

  # Get sub-matrix M^wT
  mobility_wT = mobility[3:6, 3:6]

  # Compute matrix A = M^wF - (M^wF).T
  A = mobility_wF - mobility_wF.T

  # Compute matrices B = epsilon_ikl * M^wT_jk - epsilon_jkl * M^wT_ik for l=0,1,2
  B = np.zeros( (3,3,3) )
コード例 #6
0
                             'frame' + ('%03d' % self.n) + '.png'))
            self.lwr.Write()
        self.timer_count += 0.01 * TIME_SKIP
        self.n += 1


if __name__ == '__main__':
    # Data file name where trajectory data is stored.
    data_name = sys.argv[1]

    #######
    data_file_name = os.path.join(DATA_DIR, 'boomerang', data_name)

    params, locations, orientations = read_trajectory_from_txt(data_file_name)

    initial_r_vectors = bm.get_boomerang_r_vectors_15(
        locations[0], Quaternion(orientations[0]))

    # Create blobs
    blob_sources = []
    for k in range(N_SPHERES):
        blob_sources.append(vtk.vtkSphereSource())
        blob_sources[k].SetCenter(initial_r_vectors[0][0],
                                  initial_r_vectors[0][1],
                                  initial_r_vectors[0][2])
        blob_sources[k].SetRadius(bm.A)

    if DRAW_COH:
        coh_source = vtk.vtkSphereSource()
        coh_point = bm.calculate_boomerang_coh(locations[0],
                                               Quaternion(orientations[0]))
        coh_source.SetCenter(coh_point)
コード例 #7
0
def calc_boomerang_tip(location, orientation):
    ''' Function to get boomerang cross point, which is tracked as location.'''
    r_vectors = bm.get_boomerang_r_vectors_15(location, orientation)
    tip = r_vectors[0]
    return tip
          'frame'+ ('%03d' % self.n)+'.png'))
      self.lwr.Write()
    self.timer_count += 0.01*TIME_SKIP
    self.n += 1


if __name__ == '__main__':
  # Data file name where trajectory data is stored.
  data_name = sys.argv[1]

  #######
  data_file_name = os.path.join(DATA_DIR, 'boomerang', data_name)
  
  params, locations, orientations = read_trajectory_from_txt(data_file_name)

  initial_r_vectors = bm.get_boomerang_r_vectors_15(
    locations[0], Quaternion(orientations[0]))

  # Create blobs
  blob_sources = []
  for k in range(N_SPHERES):
    blob_sources.append(vtk.vtkSphereSource())
    blob_sources[k].SetCenter(initial_r_vectors[0][0],
                              initial_r_vectors[0][1],
                              initial_r_vectors[0][2])
    blob_sources[k].SetRadius(bm.A)

  if DRAW_COH:
    coh_source = vtk.vtkSphereSource()
    coh_point = bm.calculate_boomerang_coh(
      locations[0], Quaternion(orientations[0]))
    coh_source.SetCenter(coh_point)