Exemplo n.º 1
0
  def preferred(self,vector):
    '''
    Returns True if vector is preferred, False if it is not
    '''
    xy = self.memory['preferred_direction']
    xy = (xy[0],xy[1],0) 
    if (helpers.compare_tuple(xy,(0,0,0)) or helpers.compare_tuple((
      vector[0],vector[1],0),(0,0,0))):
      return True

    return (helpers.smallest_angle((vector[0],vector[1],0),xy) <= 
      construction.beam['direction_tolerance_angle'])
Exemplo n.º 2
0
  def exists(self,e1,e2):
    '''
    Returns whether or not the beam defined by the endpoints e1 -> e2 exists
    '''
    # Let's get the box
    xi, yi, zi = self.__get_indeces(e1)

    # Cycle through the box and compare endpoints
    for name in self.model[xi][yi][zi]:
      beam = self.model[xi][yi][zi][name]
      if ((helpers.compare_tuple(beam.endpoints.i,e1,0.5) and helpers.compare_tuple(
        beam.endpoints.j,e2,0.5)) or (helpers.compare_tuple(beam.endpoints.i,e2,0.5) and
        helpers.compare_tuple(beam.endpoints.j,e1,0.5))):
        return True
    return False
Exemplo n.º 3
0
  def addjoint(self, coord, beam):
    '''
    Adds a joint (at the specified coordinate), to the beam itself. The beam 
    variable defines the which crosses this one at the joint
    '''
    # Verify that the coordinate is on the beam based on endpoints
    if not helpers.on_line(self.endpoints.i, self.endpoints.j, coord):
      return False

    else:
      coord = Coord(x=coord[0],y=coord[1],z=coord[2])
      # We cycle manually so we can compare using our compare function
      for key, beams in self.joints.items():
        # We have a key and the beam isn't already there
        if helpers.compare_tuple(key,coord) and beam not in beams:
          self.joints[key].append(beam)
          return True

      self.joints[coord] = [beam]
      return True