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

add .map_coords() function to convert all coordinates in a shape #136

Merged
merged 1 commit into from
Aug 13, 2017

Conversation

amandasaurus
Copy link
Member

I added the ability to apply a function to all coordinates. This is a general function which will change all the coordinates in a geometry. You can even change the type of the coordinates, e.g. if you want to change from f32 to f64. This gives ultimate flexibility.

Some of the other traits (e.g. Translation) could probably be rewritten to take advantage of this change, but my first simple attempt failed.

I'm not 100% happy with the syntax, p.map_coords(&|&(x, y)| ... has too many & and stuff, so I'm open to suggestions on if this can be improved.

@frewsxcv
Copy link
Member

In the future, it might be nice if these methods returned structures that implement Iterator instead of having some of the implementations call collect. The syntax is a little clunky with the &'s but I can't think of anything better right now and now point on waiting. Thanks for doing this!

bors r+

bors bot added a commit that referenced this pull request Aug 13, 2017
136: add .map_coords() function to convert all coordinates in a shape r=frewsxcv

I added the ability to apply a function to all coordinates. This is a general function which will change all the coordinates in a geometry. You can even change the type of the coordinates, e.g. if you want to change from `f32` to `f64`. This gives ultimate flexibility.

Some of the other traits (e.g. Translation) could probably be rewritten to take advantage of this change, but my first simple attempt failed.

I'm not 100% happy with the syntax, `p.map_coords(&|&(x, y)| ...` has too many `&` and stuff, so I'm open to suggestions on if this can be improved.
@bors
Copy link
Contributor

bors bot commented Aug 13, 2017

Build succeeded

@bors bors bot merged commit 82d8546 into georust:master Aug 13, 2017
@frewsxcv
Copy link
Member

Will cut a new release later when I'm back at my computer

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.

2 participants