Example #1
0
 def entitySeesEntity(self, looker, target, lastD, distance):
     if math.dist(looker.position, target.position) <= distance or self.DEBUGGING:
         arr = list(self.DX.keys())
         if lastD in self.DX:
             arr = [lastD]
         cells = []
         for d in arr:
             cells += self.getCellsFromEnttiy(looker, distance, d)
         for cell in cells:
             if self.DEBUGGING:
                 self.cells[cell[0]][cell[1]].visible = 1
                 self.cells[cell[0]][cell[1]].revealed = True
                 self.visibleCells.append(self.cells[cell[0]][cell[1]])
                 
             if target.position == cell:
                 return True
     return False
Example #2
0
def is_valid(point):
    py, px = int(point[0] // cell_size), int(point[1] // cell_size)

    # check if point is within the grid
    if py < 0 or py >= row_count or px < 0 or px >= column_count:
        return False

    # check if there is already a point in cell
    if samples_background[py][px] != -1:
        return False

    for y in range(py - 2, py + 2):
        for x in range(px - 2, px + 2):
           if 0 <= y < row_count and 0 <= x < column_count:
                if samples_background[y][x] != -1 and math.dist(samples_background[y][x], point) < r:
                    return False

    return True
Example #3
0
def printInfo(radius, Xcp, Ycp, secNum, pipeCount):
    # round values
    roundList = [radius, Xcp, Ycp]
    roundList = [round(i, 6) for i in roundList]
    radius = roundList[0]
    Xcp = roundList[1]
    Ycp = roundList[2]
    FCP = (Xcp, Ycp)
    givenR = CenterList[secNum].iloc[pipeCount, 4]
    givenC_tuple = tuple(CenterList[secNum].iloc[pipeCount, 1:3])
    print("The fitted center point is: (" + str(Xcp) + "," + str(Ycp) + ")")
    print("The as-designed center point is: (" + str(givenC_tuple[0]) + "," +
          str(givenC_tuple[1]) + ")")
    print("The distance between them is: " +
          str(round(math.dist(givenC_tuple, FCP), 7)))
    print("The fitted radius is: " + str(radius) +
          " and the actual radius is: " + str(givenR))
    print("The difference between them is: " +
          str(round(abs(givenR - radius), 7)))