θ = atan2( sin(Δlong).cos(lat2), cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong) )
Does it take into account that we may be dealing with a trapezoid rather than a rectangle
θ = atan2( sin(Δlong).cos(lat2), cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong) )
Does it take into account that we may be dealing with a trapezoid rather than a rectangle
The title and the body contain two different questions; this is an answer to the question in the title.
First rotate around the polar axis to put the first point on the prime meridian; this doesn't change the required bearing. Denoting latitude by $\theta$ and longitude by $\phi$, the coordinates of the points are now $(\theta_1,0)$ and $(\theta_2,\Delta\phi)$, respectively. Now rotate by $\theta_1$ around an equatorial axis at $\phi=\pm\pi/2$ to take the first point to the south pole. Now the required bearing is the longitude to which the second point has been rotated.
In Cartesian coordinates, the matrix of the rotation that takes the first point to the south pole is
$\pmatrix{-\sin\theta_1&0&\cos\theta_1\\0&1&0\\-\cos\theta_1&0&-\sin\theta_1}\;.$
Applying this to the second point yields
$\pmatrix{-\sin\theta_1&0&\cos\theta_1\\0&1&0\\-\cos\theta_1&0&-\sin\theta_1}\pmatrix{\cos\theta_2\cos\Delta\phi\\\cos\theta_2\sin\Delta\phi\\\sin\theta_2}=\pmatrix{\cos\theta_1\sin\theta_2-\sin\theta_1\cos\theta_2\cos\Delta\phi\\\cos\theta_2\sin\Delta\phi\\-\sin\theta_1\sin\theta_2-\cos\theta_1\cos\theta_2\cos\Delta\phi}\;.$
Then you get the bearing by calculating the longitude of that point as $\operatorname{atan2}(y,x)$.
As regards the question in the body, the derivation uses neither rectangles nor trapezoids. You may be referring to the fact that a rectangle in latitude-longitude space has roughly the shape of a trapezoid in Euclidean space. However, it's not exactly a trapezoid, and the derivation uses neither the approximation of a trapezoid, nor the even less accurate approximation of a rectangle, but calculates the bearing exactly as the local inclination of the great circle through the two points.