예제 #1
0
    def intersects_fast(self, other):
        """
        Test intersection of axes-aligned bounding boxes.
        """
        sbox = self.get_aligned_bounding_box()
        obox = other.get_aligned_bounding_box()

        flag = False
        val = np.empty((3, ), dtype=np.float64)
        for ii, ib in enumerate(self.ibox):
            val[0] = sbox[0, ib[0]]
            val[1] = sbox[1, ib[1]]
            val[2] = sbox[2, ib[2]]
            flag = np.any((obox[:, 0] <= val) & (val <= obox[:, 1]))
            if flag:
                break

        else:
            for ii, ib in enumerate(self.ibox):
                val[0] = obox[0, ib[0]]
                val[1] = obox[1, ib[1]]
                val[2] = obox[2, ib[2]]
                flag = np.any((sbox[:, 0] <= val) & (val <= sbox[:, 1]))
                if flag:
                    break

        return flag
예제 #2
0
    def get_points(self):
        """
        All points in the block.
        """
        for axis, num in ordered_iteritems(self.n_slice):
            am = self._axis_map[axis]

            shape = np.array((self.resolution[0], self.resolution[1], num))
            pb = np.zeros((3,), dtype=np.object)
            for ii in range(3):
                pb[am[ii]] = np.linspace(0, self.dims[ii], shape[ii])

            if num > 1:
                delta = pb[am[2]][1] - pb[am[2]][0]
            else:
                delta = 0.0
            x1, x2 = np.meshgrid(pb[am[0]], pb[am[1]])
            x1 = x1.ravel()
            x2 = x2.ravel()

            points = np.empty((x1.shape[0], 3), dtype=np.float64)
            points[:,am[0]] = x1
            points[:,am[1]] = x2

            yield pb, points, delta, num, axis, am
예제 #3
0
파일: intersectors.py 프로젝트: rc/gensei
    def intersects_fast(self, other):
        """
        Test intersection of axes-aligned bounding boxes.
        """
        sbox = self.get_aligned_bounding_box()
        obox = other.get_aligned_bounding_box()

        flag = False
        val = np.empty((3,), dtype=np.float64)
        for ii, ib in enumerate(self.ibox):
            val[0] = sbox[0, ib[0]]
            val[1] = sbox[1, ib[1]]
            val[2] = sbox[2, ib[2]]
            flag = np.any((obox[:,0] <= val) & (val <= obox[:,1]))
            if flag:
                break

        else:
            for ii, ib in enumerate(self.ibox):
                val[0] = obox[0, ib[0]]
                val[1] = obox[1, ib[1]]
                val[2] = obox[2, ib[2]]
                flag = np.any((sbox[:,0] <= val) & (val <= sbox[:,1]))
                if flag:
                    break

        return flag