Exemplo n.º 1
0
    def update(self, time):
        if self._destroyed:
            return False

        if self._t0 is None:
           self._t0 = time

        if self._follow is not None and not self._follow.closing() :

            d = self._follow._pos - self._pos

            T.unit_vector(d,d)

            self._dir = self._dir * (1-self._thrust) + d * self._thrust

            if time - self._t0 > 3000 or self._follow._destroyed:
                print "Not following anymore"

                self._follow = None

            Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
        else:
            # too simple to use Verlet
            Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
            self._dir += self._gravity

        self._xform = mmult(self._pos_m,self._scaling_m, T.quaternion_matrix(self._rotation))
        self._rotation = T.quaternion_multiply(self._d_rotation, self._rotation)

        # hit the floor
        if self._map(self._pos[0], self._pos[1], False) > self._pos[2]:
            self.explode()
            return False # tell the scene the missile is toast

        return True
Exemplo n.º 2
0
    def update(self, time):
        if self._destroyed:
            return False

        if self._closing:
            self._scale -= 0.01
            self._scale = max(self._scale, 0)
            self._scale_m = T.scale_matrix(self._scale)
            if self._scale == 0:
                self._destroyed = True


        self._rot = T.quaternion_multiply(self._rot_speed, self._rot)
        self._anim_m = T.quaternion_matrix(self._rot)

        self._beacon_xform = self._pos_m

        self._geom_xform = mmult(self._pos_m, self._anim_m, self._scale_m)

        return True
Exemplo n.º 3
0
    pred_r, pred_t, pred_c, colorEmb = estimator(img, cloud, pointIndex, idx)

    bs, num_p, _ = pred_c.size()
    pred_r = pred_r / (torch.norm(pred_r, dim=2).view(1, num_p, 1))
    pred_c = pred_c.view(batchSize, num_p)
    how_max, which_max = torch.max(pred_c, 1)
    pred_t = pred_t.view(batchSize * num_p, 1, 3)

    my_r = pred_r[0][which_max[0]].view(-1).cpu().data.numpy()
    # my_t = (cloud.view(batchSize * num_p, 1, 3) + pred_t)[which_max[0]].view(-1).cpu().data.numpy()
    my_t = pred_t[which_max[0]].view(-1).cpu().data.numpy()
    my_pred = np.append(my_r, my_t)

    modelPoints = modelPoints[0].cpu().detach().numpy()
    my_r = quaternion_matrix(my_r)[:3, :3]
    pred = np.dot(modelPoints, my_r.T) + my_t
    tarPoints = tarPoints[0].cpu().detach().numpy()

    if idx[0].item() in symList:
        pred = torch.from_numpy(pred.astype(np.float32)).cuda().transpose(
            1, 0).contiguous()
        tarPoints = torch.from_numpy(tarPoints.astype(
            np.float32)).cuda().transpose(1, 0).contiguous()
        inds = knn(tarPoints.unsqueeze(0), pred.unsqueeze(0))
        tarPoints = torch.index_select(tarPoints, 1, inds.view(-1) - 1)
        dis = torch.mean(torch.norm(
            (pred.transpose(1, 0) - tarPoints.transpose(1, 0)), dim=1),
                         dim=0).item()
    else:
        dis = np.mean(np.linalg.norm(pred - tarPoints, axis=1))
Exemplo n.º 4
0
 def draw(self, scene):
     self._graphics.draw(scene, mmult(self._pos_m, T.quaternion_matrix(self._rotation), self._scaling))