Skip to content

discussion: transform.tform(points, sharedTransforms=[]) ? #131

Description

@djkapner

To clean up some fusion something, I created the tform() method for InterpolatedTransform, you can see it below.In this particular case, the InterpolatedTransforms had lists with ReferenceTransforms in them, and rather than de-reference them, I added this kwarg into the call. This breaks the symmetry with all other tform methods, which kind of sucks, but... I was thinking that if all transform.tform() methods had sharedTransforms=[] then we could update ReferenceTransform and TransformList to actually have a tform method. The leaf transforms would need to be able to accept the keyword so the user would not have to worry about what kind of transform he/she is calling.

    def tform(self, points, sharedTransforms=[]):
        """transform a set of points through this transformation
        Parameters
        ----------
        points : numpy.array
            a Nx2 array of x,y points
        Returns
        -------
        numpy.array
            a Nx2 array of x,y points after transformation
        """
        dst = []

        refids = np.array([r.transformId for r in sharedTransforms])

        for ab in [self.a, self.b]:
            dst.append(np.copy(points))
            for tf in ab.tforms:
                if isinstance(tf, ReferenceTransform):
                    rind = np.argwhere(refids == tf.refId).flatten()
                    if rind.size != 1:
                        raise RenderError("Could not find unique "
                                          "sharedTransform for refId %s" %
                                          tf.refId)
                    tf = sharedTransforms[rind[0]]
                dst[-1] = tf.tform(dst[-1])

        return (1.0 - self.lambda_) * dst[0] + self.lambda_ * dst[1]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions