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

DM-10764: Rename Transform::of and Mapping::of to ::then #240

Merged
merged 1 commit into from Jun 2, 2017

Conversation

r-owen
Copy link
Contributor

@r-owen r-owen commented Jun 1, 2017

Change Transform::of(first) to Transform::then(next) to improve readability.

Change `Transform::of(first)` to `Transform::then(next)`
to improve readability.
@r-owen r-owen merged commit 288e03a into master Jun 2, 2017
Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, aside from some documentation tweaks. If Transform's constructors need to be fixed, that's clearly a different ticket.

Sorry about the mix-up!

* this Transform to the result. Its inverse shall first apply the
* inverse of this Transform, then the inverse of `first`.
* @tparam NextToEndpoint the "to" Endpoint of `next`
* @tparam FromEndpoint the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FromEndpoint is not a template parameter of then. I'm surprised Doxygen didn't complain.

* have the same number of axes.
* @exceptsafe Provides basic exception safety.
*
* More than two Transforms can be combined in series. For example:
*
* auto skyFromPixels = skyFromPupil.of(pupilFromFp)
* .of(fpFromPixels);
* auto pixelsToSky = pixelsToFP.then(fpToPupil.then(pupilToSky));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really more natural than pixelsToFP.then(fpToPupil).then(pupilToSky)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'll fix it on a new ticket.

declareMethodTemplates<GenericEndpoint, FromEndpoint, ToEndpoint>(cls);
declareMethodTemplates<Point2Endpoint, FromEndpoint, ToEndpoint>(cls);
declareMethodTemplates<SpherePointEndpoint, FromEndpoint, ToEndpoint>(cls);
declareMethodTemplates<FromEndpoint, ToEndpoint, GenericEndpoint>(cls);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this form slightly less readable because it puts the most important information at the end, though I can see why you changed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought about that. I'm still happier with it because I can instantly see that it matches the header file and other code.

@@ -535,7 +535,8 @@ int warpImage(DestImageT &destImage, SrcImageT const &srcImage,
std::vector<double> const srcParentToLocalVec = {static_cast<double>(-srcImage.getX0()),
static_cast<double>(-srcImage.getY0())};
auto const srcParentToLocalMap = ast::ShiftMap(srcParentToLocalVec);
auto const localDestToSrcMap = srcParentToLocalMap.of(destToSrc.getFrameSet()->of(destLocalToParentMap));
auto const localDestToSrcMap =
destLocalToParentMap.then(*(destToSrc.getFrameSet())).then(srcParentToLocalMap);
Copy link
Member

@kfindeisen kfindeisen Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops -- should Transform's constructors be explicit?

For that matter, why not just use destToSrc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transform's constructors are explicit because I usually make all constructors explicit under the argument that it's harmless and can avoid trouble (e.g. if a 2 argument ctor is changed to be a 1 argument ctor). But why do you ask?

As to why not just use destToSrc: it maps parent coords to parent coords, but C++ indexing of images is done using local coords. The above is needed for the code to work when xy0 is non-zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean "why not use destToSrc directly instead of getting the FrameSet from it?"....that's because everything else is a Mapping and I don't want to mix Mapping and Transform in my concatenation. And I don't want to use Transforms when Mappings will do just fine. I suppose I could change that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, I missed the part where destLocalToParentMap was not a Transform. It all makes sense now. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I ended the name with "Map". A bit of Hungarian notation that was clearly not as helpful as I'd hoped.

@ktlim ktlim deleted the tickets/DM-10764 branch August 25, 2018 06:43
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

Successfully merging this pull request may close these issues.

None yet

2 participants