-
Notifications
You must be signed in to change notification settings - Fork 200
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 translation trait #128
Conversation
.map(|point| { | ||
let new_x = point.x() + x_offset; | ||
let new_y = point.y() + y_offset; | ||
Point::new(new_x, new_y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder if we should add a Points::map
method to map coordinates to new values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on something like this which would do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow, but if @rory does, I'll just wait on the PR!
IMO rotate
/ translate
/ skew
/ scale
should all be implemented on top of a more general affine
impl that populates an affine transformation matrix with the relevant values depending on the transformation type, but that would require us to pull in a linear algebra crate…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow, but if @rory does, I'll just wait on the PR!
for example:
fn translation_matrix<T>(x_offset: T, y_offset: T, points: &[Point<T>]) -> Vec<Point<T>>
where T: Float
{
points
.iter()
.map(|point| point.map(|x, y| (x + x_offset, y + y_offset))
.collect::<Vec<_>>()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My WIP is here: https://github.com/rory/rust-geo/tree/coord_change. Specifically you can see the file here amandasaurus@b7a01f5 . My idea is to allow you to pass in a function which will take a Coordinate
and return a new Coordinate
, which gives you maximum flexibility. I don't like the name (coord_change
), but can't think of much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe map_coords
? That's what python-geojson calls it https://pypi.python.org/pypi/geojson#map-coords
bors r+ |
Build succeeded |
No description provided.