[GIS] Find end of arc given start/end angles, start point and radius

postgis

Using PostGIS, how do I work out the end point of an arc given the start point, start and end bearings (relative to true north) and radius of the arc? Eg. say I need draw an arc of 4000m radius from bearing 180 degrees to 90 degrees with the start (the 180 degree point) at POINT(10 20). How do I calculate the end point (other than approximately drawing the arc, point by point)?

This is only for short distances, so working on a plane should be OK. I can work out the distance between the start and end point using the length of chord formula and if I could just get the bearing between them as well then I could use ST_Project – but I don't know how to work out the bearing. (In the simple example above it should be 45 degrees.)

Solution:

It ended up being quite simple in the end. Thanks to whuber for explaining it very well. I wanted to put the PostGIS code here in case anyone else wants it:

centre_point := ST_Project(start_point, radius_m, normalise_angle(start_angle + pi() / 2 * CASE WHEN is_clockwise THEN 1 ELSE -1 END));
end_point := ST_Project(centre_point, radius_m, normalise_angle(end_angle + pi() / 2 * CASE WHEN is_clockwise THEN -1 ELSE 1 END));

normalise_angle is a simple function that ensures the angle is between 0 and 2PI (as required for ST_Project), start_point is a geography(Point) and radius_m is the radius in metres. Angles are in radians.

Best Answer

You don't have quite enough information, because there are two solutions. You need to specify whether you are traversing the circle positively or negatively. I will discuss the positive (counterclockwise) case; the negative case is computed in the same way with obvious changes.

For the positive direction, the circle's center is to the left of the arc. Just add 90 degrees to the bearing and travel for the radial distance and stop: that's the center. Now we know the circle's center and radius, we can find any point on it. The bearing from the center to a point on the circle is 90 degrees less than the bearing around the circle (in the positive direction).

Here are some formulas. The start point has coordinates (x1,x2), the radius is r, and the bearing is alpha. (I use the mathematical convention that 0 is due east, 90 is north.) We seek the coordinates (y1,y2) of the endpoint where the new bearing will be beta. Let the origin's coordinates be (o1,o2).

  1. The direction vector for bearing alpha is (by definition)

    (cos(alpha), sin(alpha))
    

    Rotating this 90 degrees to the left gives the unit vector

    (-sin(alpha), cos(alpha))
    

    Moving along this from (x0,x1) by distance r ends up at

    (o1,o2) = (x1,x2) + r * (-sin(alpha), cos(alpha))
    

    That's the circle's center.

  2. The bearing from the center to the end point is beta - 90 degrees. The endpoint is reached by moving a distance r in this direction, whence

    (y1,y2) = (o1,o2) + r * (cos(beta-90), sin(beta-90))
    

That's it.

Here is an animation for the start point (x1,x2) = (1000, 2000), shown in red, and the radius r = 4000. The end point (y1,y2) is shown in red. Their bearings are indicated by arrows tangent to the circles. It begins with start and stop bearings at 0 (due east) and increases the stop bearing until it reaches 360. (During this time, because the start bearing is fixed, the circle centers--shown as little black dots--do not change.) Then it increases the start bearing until it, too, reaches 360. (During this time, because the start bearing is changing, the circle centers are moving accordingly.) Both solutions are shown simultaneously: the positive direction and the negative direction.

Animated arcs

Related Question