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

HaversineIntermediate trait to find intermediate points along a great circle route #230

Merged
merged 14 commits into from
May 19, 2018

Conversation

JivanRoquet
Copy link
Contributor

@JivanRoquet JivanRoquet commented May 16, 2018

Given two existing points, implements the ability to find intermediate points along the great circle route joining the initial points.

The haversine_intermediate method takes three parameters:

  • &self
  • other: &Point<T> which represents the other side of the great circle route
  • f: T which represents the fraction of the route at which to put the intermediate point

f must be included between T::zero() and T::one().

Return value is Point<T>.

let y = a * lat1.cos() * lon1.sin() + b * lat2.cos() * lon2.sin();
let z = a * lat1.sin() + b * lat2.sin();

let dxy = (x.powi(2) + y.powi(2)).sqrt();
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be the same as x.hypot(y)

https://docs.rs/num/0.1.42/num/trait.Float.html#tymethod.hypot

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!

@JivanRoquet
Copy link
Contributor Author

Added the ability to "fill" a great circle route with intermediate points at regular interval, as described in issue #228.

@JivanRoquet
Copy link
Contributor Author

up? :)

@frewsxcv
Copy link
Member

lgtm, thanks!

bors r+

bors bot added a commit that referenced this pull request May 19, 2018
230: HaversineIntermediate trait to find intermediate points along a great circle route r=frewsxcv a=JivanRoquet

Given two existing points, implements the ability to find intermediate points along the great circle route joining the initial points.

The `haversine_intermediate` method takes three parameters:

- `&self`
- `other: &Point<T>` which represents the other side of the great circle route
- `f: T` which represents the fraction of the route at which to put the intermediate point

`f` must be included between `T::zero()` and `T::one()`.

Return value is `Point<T>`.

Co-authored-by: Jivan Roquet <jivan.roquet@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 19, 2018

Build succeeded

@bors bors bot merged commit c08f374 into georust:master May 19, 2018
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.

3 participants