How to use the pytransform3d.transformations.invert_transform function in pytransform3d

To help you get started, we’ve selected a few pytransform3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rock-learning / pytransform3d / pytransform3d / camera.py View on Github external
focal_length : float
        Focal length of the camera

    image_center : array-like, shape (2,), optional (default: image_size / 2)
        Center of the image

    kappa : float, optional (default: 0)
        TODO document

    Returns
    -------
    P_img : array-like, shape (n_points, 2)
        Points on image
    """
    world2cam = invert_transform(cam2world)
    P_cam = transform(world2cam, P_world)
    P_sensor = cam2sensor(P_cam, focal_length, kappa)
    P_img = sensor2img(P_sensor, sensor_size, image_size, image_center)
    return P_img
github rock-learning / pytransform3d / pytransform3d / transform_manager.py View on Github external
Returns
        -------
        consistent : bool
            Is the graph consistent, i.e. is A2B always the same as the inverse
            of B2A?
        """
        consistent = True
        for n1 in self.nodes:
            for n2 in self.nodes:
                try:
                    n1_to_n2 = self.get_transform(n1, n2)
                    n2_to_n1 = self.get_transform(n2, n1)
                    consistent = (consistent and
                                  np.allclose(n1_to_n2,
                                              invert_transform(n2_to_n1)))
                except KeyError:
                    pass  # Frames are not connected
        return consistent
github rock-learning / pytransform3d / pytransform3d / transform_manager.py View on Github external
Returns
        -------
        A2B : array-like, shape (4, 4)
            Homogeneous matrix that represents the transform from 'from_frame'
            to 'to_frame'
        """
        if from_frame not in self.nodes:
            raise KeyError("Unknown frame '%s'" % from_frame)
        if to_frame not in self.nodes:
            raise KeyError("Unknown frame '%s'" % to_frame)

        if (from_frame, to_frame) in self.transforms:
            return self.transforms[(from_frame, to_frame)]
        elif (to_frame, from_frame) in self.transforms:
            return invert_transform(self.transforms[(to_frame, from_frame)])
        else:
            i = self.nodes.index(from_frame)
            j = self.nodes.index(to_frame)
            if not np.isfinite(self.dist[i, j]):
                raise KeyError("Cannot compute path from frame '%s' to "
                               "frame '%s'." % (from_frame, to_frame))

            path = self._shortest_path(i, j)
            return self._path_transform(path)