Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
djkapner opened this issue Dec 12, 2018 · 0 comments
Open

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

djkapner opened this issue Dec 12, 2018 · 0 comments

Comments

@djkapner
Copy link
Contributor

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant