The angle, azimuth, and distance are a form of spherical coordinates for the displacement from the initial position:
The horizontal displacement is a multiple of the distance. That multiple depends on the dip. The multiple--by definition--is called the cosine of the dip.
The vertical displacement is also a multiple of the distance. That multiple also depends only on the dip. Once again, by definition, the multiple is called the sine of the dip. But we must be careful to consider the dip a negative angle.
The northing and easting are, in a similar fashion, multiples of the horizontal displacement. Assuming the azimuth is measured east of north, the multiple to use for the northern displacement is the cosine of the azimuth and the multiple to use for the eastern displacement is the sine of the azimuth.
In the example given,
cos(dip) = cos(-65 degrees) = cos(-65/180 * pi radians) = 0.4226183;
sin(dip) = sin(-65/180 * pi radians) = -0.9063078.
Therefore the vertical displacement equals 150 * -0.9063078 = -135.9462
. For the sake of continuing the calculation, I will assume the distance and the elevation are measured in the same units. (If not, then of course the units have to be made commensurable before adding them.) Whence the elevation of at the end of the displacement is 1060 + -135.9462 = 924.0538
.
Similarly the horizontal displacement equals 150 * 0.4226183 = 63.39274
. In order to continue the calculation, I will assume the distance and the (easting, northing) coordinates are measured in the same units. (If not, then the units have to be made commensurable before proceeding.) We compute
cos(azimuth) = cos(45 degrees) = cos(45/180 * pi radians) = 0.7071068;
sin(azimuth) = sin(45/180 * pi radians) = 0.7071068.
Therefore the northern displacement is 63.39274 * 0.7071068 = 44.82544
and the eastern displacement works out to the same (because the sine and cosine of this particular azimuth happen to be equal). Whence the ground coordinates of the end of the displacement are
(290694, 715927) + (44.82544, 44.82544) = (290738.82544, 715971.82544).
As a double-check let's compute the distance between the start and end:
distance((290694, 715927, 1060), (290738.82544, 715971.82544, 924.0538))
= sqrt((290694 - 290738.82544)^2 + (715927 - 715971.82544)^2 + (1060 - 924.0538)^2)
= 150.0000,
as intended. We can also plot the two points and visually check that the angles look about right: that's a good idea when testing out these calculations on an unfamiliar computing platform, because it detects the common mistakes of (1) confusing radians and degrees, (2) mixing up sines and cosines, (3) not using the correct signs for the angles, and (4) not performing units conversions where needed.
For an answer on the geodesic, your example 2 is the closest, but when you ran it you should have seen a couple warnings,
NOTICE: Coordinate values were coerced into range [-180 -90, 180 90] for GEOGRAPHY
NOTICE: Coordinate values were coerced into range [-180 -90, 180 90] for GEOGRAPHY
because your input coordinates are not in lon/lat, they are in web mercator. So, hybridizing your example 1 and 2, we get,
with pts as (
select
st_transform(st_setsrid(st_makepoint(-81328.998084106,7474929.8690234), 900913), 4326)::geography as a,
st_transform(st_setsrid(st_makepoint(4125765.0381464,7474929.8690234), 900913), 4326)::geography as b
)
select st_astext(a) as a, st_astext(b) as b, degrees(st_azimuth(a,b)) from pts;
which returns (less some extraneous digits)
a | b | degrees
----------------------+----------------------+--------
POINT(-0.730 55.578) | POINT(37.062 55.578) | 74.231
and perhaps makes you wonder why, if a and b are at the same latitude the azimuth is not 90? The answer is that on the geodesic shortest paths are great circles, so really it's the same reason that flights from Seattle to London go over Greenland, but not over the Great Lakes. (Any west/east trip in the northern hemisphere will bend to the north, and the bend will be bigger the further north you go. Vice versa in the southern hemisphere.)
Best Answer
As commented by @whuber: