Example #1
0
    def win(self, p, q):
        p, q = np.asarray(p), np.asarray(q)
        assert p.shape == q.shape
        if p.shape == ():
            return self.win([p], [q])[0]

        r = np.zeros(p.shape, dtype=np.bool)

        i = intersects(p, q, self.goal[0], self.goal[1])
        op = orient(self.goal[0], self.goal[1], p)
        oq = orient(self.goal[0], self.goal[1], q)
        r[i & (-1 == op) & (op < oq)] = True

        r[p == q] = False
        return r
Example #2
0
    def win(self, p, q):
        p, q = np.asarray(p), np.asarray(q)
        assert p.shape == q.shape
        if p.shape == ():
            return self.win([p], [q])[0]

        r = np.zeros(p.shape, dtype=np.bool)

        i = intersects(p, q, self.goal[0], self.goal[1])
        op = orient(self.goal[0], self.goal[1], p)
        oq = orient(self.goal[0], self.goal[1], q)
        r[i & (-1 == op) & (op < oq)] = True

        r[p == q] = False
        return r
Example #3
0
    def valid(self, p, q):
        p, q = np.asarray(p), np.asarray(q)
        assert p.shape == q.shape
        if p.shape == ():
            return self.valid([p], [q])[0]
        i = intersects(p, q, self.goal[0], self.goal[1])
        op = orient(self.goal[0], self.goal[1], p)
        oq = orient(self.goal[0], self.goal[1], q)

        r = np.ones(p.shape, dtype=np.bool)
        r[i & (op >= oq)] = False

        i2 = intersects(self.obstacle_p, self.obstacle_q, p, q)
        i2 = i2.any(axis=tuple(range(self.obstacle_p.ndim)))
        r[i2] = False
        return r
Example #4
0
    def valid(self, p, q):
        p, q = np.asarray(p), np.asarray(q)
        assert p.shape == q.shape
        if p.shape == ():
            return self.valid([p], [q])[0]
        i = intersects(p, q, self.goal[0], self.goal[1])
        op = orient(self.goal[0], self.goal[1], p)
        oq = orient(self.goal[0], self.goal[1], q)

        r = np.ones(p.shape, dtype=np.bool)
        r[i & (op >= oq)] = False

        i2 = intersects(self.obstacle_p, self.obstacle_q, p, q)
        i2 = i2.any(axis=tuple(range(self.obstacle_p.ndim)))
        r[i2] = False
        return r