Boost logo

Geometry :

Subject: [ggl] Move a point_ll by a distance
From: Barend Gehrels (Barend.Gehrels)
Date: 2009-10-20 04:45:31

Hi Richard,

Welcome to the list!

> this is my first post to this list.
> I used the ggl for distance calculation for some time now, but now I
> want to do it the other way around, and didn't find how in the
> documentation.
> I have some point_ll that I want to move to a certain directory[deg] by
> a certain distance[km].
> I looked at
> - add_point
> - add_value
> but they don't seem to be what I want.
> So, how would I do that?
It is not there, but (considering the earth as a sphere) it is not
difficult because the necessary formulae are on this (great) website:

It is useful, so I added it to an example, which is (now) here:

It contains functions get_course (in case you need it) and
point_at_distance (the one you're looking for). For Amsterdam-Paris it
works great:

// Other way round: have Amsterdam and go 430 km to the south (first calculate direction)
double tc = get_course(amsterdam_rad, paris_rad);
std::cout << "Course: " << (tc * ggl::math::r2d) << std::endl;

point_ll_deg paris_calculated;
point_at_distance(amsterdam_rad, 430 * 1000.0, tc, average_earth_radius, paris_calculated);
std::cout << "Paris calculated (degree): " << ggl::dsv(paris_calculated) << std::endl;

and it outputs:
Paris: (2.33306, 48.8667)
Course: 154.156037
Paris calculated (degree): (2.33150351, 48.8643588)

Note that the point is calculated using spherical formulae, so not
geodetical. If those formulae exist, I'm interested (didn't search for
them this morning). If not, and the spherical is not satisfactory, you
could start with the spherical and than make the point more precise in a
few steps using the Andoyer or Vincenty distance.

By the way, thanks for using GGL. Are we allowed to mention that on the
website? If yes, can you describe your use-case in one or two lines?

Regards, Barend

-------------- next part --------------
An HTML attachment was scrubbed...

Geometry list run by mateusz at