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

Intermediate points on great circle route between two Points #228

Closed
JivanRoquet opened this issue May 16, 2018 · 2 comments
Closed

Intermediate points on great circle route between two Points #228

JivanRoquet opened this issue May 16, 2018 · 2 comments

Comments

@JivanRoquet
Copy link
Contributor

JivanRoquet commented May 16, 2018

One interesting addition to the library would be the ability, given two distinct initial points anywhere on Earth, to compute any intermediate point located on the Great Circle path between the two initial points.

impl<T> HaversineIntermediate<T> for Point<T>
where T: Float + Primivite
{
    fn haversine_intermediate(&self, other: &Point<T>, f: T) -> Point<T> {
        // return the intermediate point on the Great Circle between self and other
        // where f is the fraction along Great Circle route
        // (f = 0.0 returns self , f = 1.0 returns other)
    }
}

let p1 = Point::new(50.0, 20.0);
let p2 = Point::new(20.0, 10.0);

let i10  = p1.haversine_intermediate(p2, 0.1); // at 10% of the way between p1 and p2
let i20  = p1.haversine_intermediate(p2, 0.2); // at 20% of the way between p1 and p2
let i50  = p1.haversine_intermediate(p2, 0.5); // halfway between p1 and p2

let i0   = p1.haversine_intermediate(p2, 0.0);
let i100 = p1.haversine_intermediate(p2, 1.0);

assert_eq!(i0, p1);
assert_eq!(i100, p2);

Resources:

http://www.edwilliams.org/avform.htm#Intermediate
http://fraserchapman.blogspot.co.uk/2008/09/intermediate-points-on-great-circle.html

@JivanRoquet JivanRoquet changed the title Intermediate Points on Great Circle between two Points Intermediate points on great circle route between two Points May 16, 2018
@JivanRoquet
Copy link
Contributor Author

See PR #230

@JivanRoquet
Copy link
Contributor Author

JivanRoquet commented May 16, 2018

Feature: adding a method returning a sequence of points given a maximum distance between points.

Spec draft:

fn haversine_intermediate_fill(&self, other: &Point<T>, max_dist: T, include_ends: bool) -> Vec<Point<T>> {
    // return all the waypoints between and including self and other,
    // so that no two consecutive waypoints are distant of more than max_dist
    // and pick the waypoints so that they are evenly distributed along the path
}

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