gistfile1.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:occ_grid_map 作者: ku-ya 项目源码 文件源码
def initialize(self):
        (cube_result, cube_hit_t_min, cube_hit_t_max) = self.grid.aabb.intersects(self.ray)
        if cube_result:
            cube_hit_point = self.ray.origin + (cube_hit_t_min) * self.ray.direction
            self.t_min = cube_hit_t_min
            self.cube_hit_t_min = cube_hit_t_min

#            print "DDA: Cube Hit Point:", cube_hit_point

            self.step_x = np.copysign(1., self.ray.direction[0])
            self.step_y = np.copysign(1., self.ray.direction[1])

            self.t_delta_x = (self.step_x / self.ray.direction[0])
            self.t_delta_y = (self.step_y / self.ray.direction[1])

            self.t_max_x = diff_distance(cube_hit_point[0], self.ray.direction[0])
            self.t_max_y = diff_distance(cube_hit_point[1], self.ray.direction[1])

            if cube_hit_point[0] < 0:
                cube_hit_point[0] -= 1
            if cube_hit_point[1] < 0:
                cube_hit_point[1] -= 1
            self.voxel = np.array(cube_hit_point, dtype=int)
            # print("DDA: Initial Voxel:" , self.voxel)
            '''
            this conditional solves the problem where the "cube_hit_point" is just
            outside the grid because of floating point imprecision.
            '''
            while self.voxel[0] < self.grid.aabb.low[0] or self.voxel[1] < self.grid.aabb.low[1]\
            or self.voxel[0] >= self.grid.aabb.high[0] or self.voxel[1] >= self.grid.aabb.high[1]:
                print("DDA: Skyping:", self.voxel)
                if not self.step():
                    return False

            return True
        else:
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号