Pull Constant from Atan2 Function

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am trying to calculate intersection Latitude value based on given coordinates and intersect Longitude.



$begin align
b &= text is bearing in radians \
Lat_1 &= text is Latitude 1 \
Lat_2 &= text is Latitude 2 \
Lon_1 &= text is Longitude 1 \
Lon_2 &= text is Longitude 2 \
end align$



$begin align
y &= sin(Lon_2-Lon_1) times cos Lat_2 \
x &= cos Lat_1 times sin Lat_2-sin Lat_1 times cos Lat_2 times cos(Lon_2-Lon_1) \
end align$



so $text atan2(y, x)$ should give me the bearing between these coordinates.



If $b = text atan2 ((sin(Lon_2-Lon_1) times cos Lat_2), (cos Lat_1 times sin Lat_2- sin Lat_1 times cos Lat_2 times cos (Lon_2-Lon_1)))$



$Lat_2$ = ?







share|cite|improve this question





















  • Please use MathJax to format posts on this site.
    – saulspatz
    Jul 25 at 14:21














up vote
0
down vote

favorite












I am trying to calculate intersection Latitude value based on given coordinates and intersect Longitude.



$begin align
b &= text is bearing in radians \
Lat_1 &= text is Latitude 1 \
Lat_2 &= text is Latitude 2 \
Lon_1 &= text is Longitude 1 \
Lon_2 &= text is Longitude 2 \
end align$



$begin align
y &= sin(Lon_2-Lon_1) times cos Lat_2 \
x &= cos Lat_1 times sin Lat_2-sin Lat_1 times cos Lat_2 times cos(Lon_2-Lon_1) \
end align$



so $text atan2(y, x)$ should give me the bearing between these coordinates.



If $b = text atan2 ((sin(Lon_2-Lon_1) times cos Lat_2), (cos Lat_1 times sin Lat_2- sin Lat_1 times cos Lat_2 times cos (Lon_2-Lon_1)))$



$Lat_2$ = ?







share|cite|improve this question





















  • Please use MathJax to format posts on this site.
    – saulspatz
    Jul 25 at 14:21












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to calculate intersection Latitude value based on given coordinates and intersect Longitude.



$begin align
b &= text is bearing in radians \
Lat_1 &= text is Latitude 1 \
Lat_2 &= text is Latitude 2 \
Lon_1 &= text is Longitude 1 \
Lon_2 &= text is Longitude 2 \
end align$



$begin align
y &= sin(Lon_2-Lon_1) times cos Lat_2 \
x &= cos Lat_1 times sin Lat_2-sin Lat_1 times cos Lat_2 times cos(Lon_2-Lon_1) \
end align$



so $text atan2(y, x)$ should give me the bearing between these coordinates.



If $b = text atan2 ((sin(Lon_2-Lon_1) times cos Lat_2), (cos Lat_1 times sin Lat_2- sin Lat_1 times cos Lat_2 times cos (Lon_2-Lon_1)))$



$Lat_2$ = ?







share|cite|improve this question













I am trying to calculate intersection Latitude value based on given coordinates and intersect Longitude.



$begin align
b &= text is bearing in radians \
Lat_1 &= text is Latitude 1 \
Lat_2 &= text is Latitude 2 \
Lon_1 &= text is Longitude 1 \
Lon_2 &= text is Longitude 2 \
end align$



$begin align
y &= sin(Lon_2-Lon_1) times cos Lat_2 \
x &= cos Lat_1 times sin Lat_2-sin Lat_1 times cos Lat_2 times cos(Lon_2-Lon_1) \
end align$



so $text atan2(y, x)$ should give me the bearing between these coordinates.



If $b = text atan2 ((sin(Lon_2-Lon_1) times cos Lat_2), (cos Lat_1 times sin Lat_2- sin Lat_1 times cos Lat_2 times cos (Lon_2-Lon_1)))$



$Lat_2$ = ?









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 25 at 22:49
























asked Jul 25 at 14:16









Mapster

33




33











  • Please use MathJax to format posts on this site.
    – saulspatz
    Jul 25 at 14:21
















  • Please use MathJax to format posts on this site.
    – saulspatz
    Jul 25 at 14:21















Please use MathJax to format posts on this site.
– saulspatz
Jul 25 at 14:21




Please use MathJax to format posts on this site.
– saulspatz
Jul 25 at 14:21










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










I notice that your formula measures latitude up and down from the equator
(the geographer's convention) rather than down from the pole
(the mathematical convention).
Let's use your convention (relative to the equator).



I find the formulas easier to work with when I write $phi$ for latitude
and $lambda$ for longitude.
Given your initial latitude $phi_1$ and longitude $lambda_1$ and the bearing $b$ toward the desired point at latitude $phi_2,$
let
$$
a = fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$
and compute the longitude $lambda_0$ at which the latitude of the great circle is maximized as follows:
$$
lambda_0 = lambda_1 pm arccosleft( fractan phi_1a right).
$$
You can determine the sign to use for $pm$ by considering the quadrant in which the angle $b$ lies.
For example, if $0 < b < 90^circ,$ then your general direction of travel along the circle is eastward and the maximum latitude is less than halfway around the circle in your direction of travel, so you take the $+$ sign.



Finally, let
$$
lambda_2
= lambda_0 pm arccosleft( fractan phi_2a right),
$$
using the angle $b$ and the direction from $phi_1$ to $phi_2$ to determine which sign to use for $pm.$
For example, if $0 < b < 90^circ$ and $phi_2 > phi_1,$ then you are traveling generally eastward but will reach latitude $phi_2$ before
$phi_max,$ so you should use the $-$ sign.




Here is a derivation of the formulas.



We have Clairaut's formula,
$$
sin psi cos phi = textconstant,
$$
where $psi$ is the bearing along the great circle at a point at
latitude $phi,$
and the implicit equation of a great circle,
$$
tan phi = a cos(lambda - lambda_0),
$$
where $phi$ and $lambda$ are the latitude and longitude of a point on the circle and where $a$ and $lambda_0$ are constants.
(See this question
but convert the latitude to your convention).



At the minimum and maximum latitudes of a great circle, the course is
$90^circ$ or $270^circ,$ so the absolute value of the constant in Clairaut's formula is $cos phi_max,$ where $phi_max$ is the maximum latitude of the great circle.
Plugging in your initial latitude $phi_1$ and your bearing $b,$
$$ cosphi_max = lvert sin b cos phi_1rvert. $$
From the identity $tanalpha = fracsqrt1 - cos^2alphacosalpha,$
we conclude that
$$
tan phi_max
= fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$



In the implicit equation, $a$ is the maximum value of the right-hand side,
while the left-hand side is maximized when $phi = phi_max,$ so
$$a = tanphi_max.$$
Moreover, $lambda_0$ is the longitude at which the maximum latitude is reached.
Plugging in your initial conditions,
$$
tan phi_1 = a cos(lambda_1 - lambda_0),
$$
where $lambda_1$ is your initial longitude.
It follows that
$$
cos(lambda_1 - lambda_0) = fractan phi_1a
$$
and that
$$
lambda_0
= lambda_1 pm arccosleft( fractan phi_1a right).
$$



Now that we know $a$ and $lambda_0,$ we can solve for $lambda_2$ in the equation
$$
tan phi_2 = tan phi_max cos(lambda_2 - lambda_0).
$$
The result is shown in the first part of this answer.




Having worked through all of that, I might still be inclined to transfer to Cartesian coordinates in order to do the work.
It is simple enough to find unit vectors pointing due north and due east along the surface of the Earth at any latitude and longitude, and from those and the bearing along a great circle through that point, get a vector perpendicular to the great circle.
If the coordinates of that vector are $(x_0,y_0,z_0),$
then $lambda_0 = textatan2(y_0, x_0).$
You can then get the angle $lvertlambda_2 - lambda_0rvert$
by constructing some right triangles and applying a little trig.



It's also possible to solve for $lambda_2$ in the formula in the question,
but it seems uglier to do it that way.






share|cite|improve this answer





















  • Hi David, thanks for the answer. Do I use degree values or radians?
    – Mapster
    Jul 26 at 17:04










  • Most software libraries want the arguments of their trig functions to be in radians. That should be in the software documentation. If in doubt, try computing something like $cos(pi),$ which should be $-1$ if $pi$ is in radians. If you somehow have a "cosine" function that expects degrees, then $cos(pi)$ will be a little less than $1.$
    – David K
    Jul 26 at 17:12










  • I was trying to implement the answer to my solution. In my case I added 2 knows coordinates; $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$. I tried to find $phi_3$ when $lambda_3$ is 180 which will be $pi$. So $$phi_1 = 0.72161510588331557 , lambda_1 = 0.038397243543875255 and phi_2 = 0.71462506222907829, lambda_2 = 0.71462506222907829 $$ , and my bearing $$ b = 1.5908821682714704 $$. I tried to find $phi_3$ but ended up with negative value $$ phi_3 = -41.291340055344634$$ which it shouldn't be. I used every value in radians then converted it to degrees at the end.
    – Mapster
    Jul 26 at 17:48











  • I calculated the rhumb line bearing in radians between $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$
    – Mapster
    Jul 26 at 17:59










  • Actually, if you have one point on the great circle at $phi_1approx 0.7216, lambda_1 approx 0.0384,$ then I would expect the circle also to pass through a point with coordinates $phiapprox-0.7216,lambdaapproxpi+0.0384,$ exactly halfway around the circle. And that would come out to about $-41$ degrees latitude. Your point $phi_3,lambda_3$ would be close to that point on the great circle as well. So if the $phi_3$ you showed is in degrees, it looks just about right.
    – David K
    Jul 26 at 21:07











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2862455%2fpull-constant-from-atan2-function%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










I notice that your formula measures latitude up and down from the equator
(the geographer's convention) rather than down from the pole
(the mathematical convention).
Let's use your convention (relative to the equator).



I find the formulas easier to work with when I write $phi$ for latitude
and $lambda$ for longitude.
Given your initial latitude $phi_1$ and longitude $lambda_1$ and the bearing $b$ toward the desired point at latitude $phi_2,$
let
$$
a = fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$
and compute the longitude $lambda_0$ at which the latitude of the great circle is maximized as follows:
$$
lambda_0 = lambda_1 pm arccosleft( fractan phi_1a right).
$$
You can determine the sign to use for $pm$ by considering the quadrant in which the angle $b$ lies.
For example, if $0 < b < 90^circ,$ then your general direction of travel along the circle is eastward and the maximum latitude is less than halfway around the circle in your direction of travel, so you take the $+$ sign.



Finally, let
$$
lambda_2
= lambda_0 pm arccosleft( fractan phi_2a right),
$$
using the angle $b$ and the direction from $phi_1$ to $phi_2$ to determine which sign to use for $pm.$
For example, if $0 < b < 90^circ$ and $phi_2 > phi_1,$ then you are traveling generally eastward but will reach latitude $phi_2$ before
$phi_max,$ so you should use the $-$ sign.




Here is a derivation of the formulas.



We have Clairaut's formula,
$$
sin psi cos phi = textconstant,
$$
where $psi$ is the bearing along the great circle at a point at
latitude $phi,$
and the implicit equation of a great circle,
$$
tan phi = a cos(lambda - lambda_0),
$$
where $phi$ and $lambda$ are the latitude and longitude of a point on the circle and where $a$ and $lambda_0$ are constants.
(See this question
but convert the latitude to your convention).



At the minimum and maximum latitudes of a great circle, the course is
$90^circ$ or $270^circ,$ so the absolute value of the constant in Clairaut's formula is $cos phi_max,$ where $phi_max$ is the maximum latitude of the great circle.
Plugging in your initial latitude $phi_1$ and your bearing $b,$
$$ cosphi_max = lvert sin b cos phi_1rvert. $$
From the identity $tanalpha = fracsqrt1 - cos^2alphacosalpha,$
we conclude that
$$
tan phi_max
= fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$



In the implicit equation, $a$ is the maximum value of the right-hand side,
while the left-hand side is maximized when $phi = phi_max,$ so
$$a = tanphi_max.$$
Moreover, $lambda_0$ is the longitude at which the maximum latitude is reached.
Plugging in your initial conditions,
$$
tan phi_1 = a cos(lambda_1 - lambda_0),
$$
where $lambda_1$ is your initial longitude.
It follows that
$$
cos(lambda_1 - lambda_0) = fractan phi_1a
$$
and that
$$
lambda_0
= lambda_1 pm arccosleft( fractan phi_1a right).
$$



Now that we know $a$ and $lambda_0,$ we can solve for $lambda_2$ in the equation
$$
tan phi_2 = tan phi_max cos(lambda_2 - lambda_0).
$$
The result is shown in the first part of this answer.




Having worked through all of that, I might still be inclined to transfer to Cartesian coordinates in order to do the work.
It is simple enough to find unit vectors pointing due north and due east along the surface of the Earth at any latitude and longitude, and from those and the bearing along a great circle through that point, get a vector perpendicular to the great circle.
If the coordinates of that vector are $(x_0,y_0,z_0),$
then $lambda_0 = textatan2(y_0, x_0).$
You can then get the angle $lvertlambda_2 - lambda_0rvert$
by constructing some right triangles and applying a little trig.



It's also possible to solve for $lambda_2$ in the formula in the question,
but it seems uglier to do it that way.






share|cite|improve this answer





















  • Hi David, thanks for the answer. Do I use degree values or radians?
    – Mapster
    Jul 26 at 17:04










  • Most software libraries want the arguments of their trig functions to be in radians. That should be in the software documentation. If in doubt, try computing something like $cos(pi),$ which should be $-1$ if $pi$ is in radians. If you somehow have a "cosine" function that expects degrees, then $cos(pi)$ will be a little less than $1.$
    – David K
    Jul 26 at 17:12










  • I was trying to implement the answer to my solution. In my case I added 2 knows coordinates; $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$. I tried to find $phi_3$ when $lambda_3$ is 180 which will be $pi$. So $$phi_1 = 0.72161510588331557 , lambda_1 = 0.038397243543875255 and phi_2 = 0.71462506222907829, lambda_2 = 0.71462506222907829 $$ , and my bearing $$ b = 1.5908821682714704 $$. I tried to find $phi_3$ but ended up with negative value $$ phi_3 = -41.291340055344634$$ which it shouldn't be. I used every value in radians then converted it to degrees at the end.
    – Mapster
    Jul 26 at 17:48











  • I calculated the rhumb line bearing in radians between $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$
    – Mapster
    Jul 26 at 17:59










  • Actually, if you have one point on the great circle at $phi_1approx 0.7216, lambda_1 approx 0.0384,$ then I would expect the circle also to pass through a point with coordinates $phiapprox-0.7216,lambdaapproxpi+0.0384,$ exactly halfway around the circle. And that would come out to about $-41$ degrees latitude. Your point $phi_3,lambda_3$ would be close to that point on the great circle as well. So if the $phi_3$ you showed is in degrees, it looks just about right.
    – David K
    Jul 26 at 21:07















up vote
0
down vote



accepted










I notice that your formula measures latitude up and down from the equator
(the geographer's convention) rather than down from the pole
(the mathematical convention).
Let's use your convention (relative to the equator).



I find the formulas easier to work with when I write $phi$ for latitude
and $lambda$ for longitude.
Given your initial latitude $phi_1$ and longitude $lambda_1$ and the bearing $b$ toward the desired point at latitude $phi_2,$
let
$$
a = fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$
and compute the longitude $lambda_0$ at which the latitude of the great circle is maximized as follows:
$$
lambda_0 = lambda_1 pm arccosleft( fractan phi_1a right).
$$
You can determine the sign to use for $pm$ by considering the quadrant in which the angle $b$ lies.
For example, if $0 < b < 90^circ,$ then your general direction of travel along the circle is eastward and the maximum latitude is less than halfway around the circle in your direction of travel, so you take the $+$ sign.



Finally, let
$$
lambda_2
= lambda_0 pm arccosleft( fractan phi_2a right),
$$
using the angle $b$ and the direction from $phi_1$ to $phi_2$ to determine which sign to use for $pm.$
For example, if $0 < b < 90^circ$ and $phi_2 > phi_1,$ then you are traveling generally eastward but will reach latitude $phi_2$ before
$phi_max,$ so you should use the $-$ sign.




Here is a derivation of the formulas.



We have Clairaut's formula,
$$
sin psi cos phi = textconstant,
$$
where $psi$ is the bearing along the great circle at a point at
latitude $phi,$
and the implicit equation of a great circle,
$$
tan phi = a cos(lambda - lambda_0),
$$
where $phi$ and $lambda$ are the latitude and longitude of a point on the circle and where $a$ and $lambda_0$ are constants.
(See this question
but convert the latitude to your convention).



At the minimum and maximum latitudes of a great circle, the course is
$90^circ$ or $270^circ,$ so the absolute value of the constant in Clairaut's formula is $cos phi_max,$ where $phi_max$ is the maximum latitude of the great circle.
Plugging in your initial latitude $phi_1$ and your bearing $b,$
$$ cosphi_max = lvert sin b cos phi_1rvert. $$
From the identity $tanalpha = fracsqrt1 - cos^2alphacosalpha,$
we conclude that
$$
tan phi_max
= fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$



In the implicit equation, $a$ is the maximum value of the right-hand side,
while the left-hand side is maximized when $phi = phi_max,$ so
$$a = tanphi_max.$$
Moreover, $lambda_0$ is the longitude at which the maximum latitude is reached.
Plugging in your initial conditions,
$$
tan phi_1 = a cos(lambda_1 - lambda_0),
$$
where $lambda_1$ is your initial longitude.
It follows that
$$
cos(lambda_1 - lambda_0) = fractan phi_1a
$$
and that
$$
lambda_0
= lambda_1 pm arccosleft( fractan phi_1a right).
$$



Now that we know $a$ and $lambda_0,$ we can solve for $lambda_2$ in the equation
$$
tan phi_2 = tan phi_max cos(lambda_2 - lambda_0).
$$
The result is shown in the first part of this answer.




Having worked through all of that, I might still be inclined to transfer to Cartesian coordinates in order to do the work.
It is simple enough to find unit vectors pointing due north and due east along the surface of the Earth at any latitude and longitude, and from those and the bearing along a great circle through that point, get a vector perpendicular to the great circle.
If the coordinates of that vector are $(x_0,y_0,z_0),$
then $lambda_0 = textatan2(y_0, x_0).$
You can then get the angle $lvertlambda_2 - lambda_0rvert$
by constructing some right triangles and applying a little trig.



It's also possible to solve for $lambda_2$ in the formula in the question,
but it seems uglier to do it that way.






share|cite|improve this answer





















  • Hi David, thanks for the answer. Do I use degree values or radians?
    – Mapster
    Jul 26 at 17:04










  • Most software libraries want the arguments of their trig functions to be in radians. That should be in the software documentation. If in doubt, try computing something like $cos(pi),$ which should be $-1$ if $pi$ is in radians. If you somehow have a "cosine" function that expects degrees, then $cos(pi)$ will be a little less than $1.$
    – David K
    Jul 26 at 17:12










  • I was trying to implement the answer to my solution. In my case I added 2 knows coordinates; $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$. I tried to find $phi_3$ when $lambda_3$ is 180 which will be $pi$. So $$phi_1 = 0.72161510588331557 , lambda_1 = 0.038397243543875255 and phi_2 = 0.71462506222907829, lambda_2 = 0.71462506222907829 $$ , and my bearing $$ b = 1.5908821682714704 $$. I tried to find $phi_3$ but ended up with negative value $$ phi_3 = -41.291340055344634$$ which it shouldn't be. I used every value in radians then converted it to degrees at the end.
    – Mapster
    Jul 26 at 17:48











  • I calculated the rhumb line bearing in radians between $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$
    – Mapster
    Jul 26 at 17:59










  • Actually, if you have one point on the great circle at $phi_1approx 0.7216, lambda_1 approx 0.0384,$ then I would expect the circle also to pass through a point with coordinates $phiapprox-0.7216,lambdaapproxpi+0.0384,$ exactly halfway around the circle. And that would come out to about $-41$ degrees latitude. Your point $phi_3,lambda_3$ would be close to that point on the great circle as well. So if the $phi_3$ you showed is in degrees, it looks just about right.
    – David K
    Jul 26 at 21:07













up vote
0
down vote



accepted







up vote
0
down vote



accepted






I notice that your formula measures latitude up and down from the equator
(the geographer's convention) rather than down from the pole
(the mathematical convention).
Let's use your convention (relative to the equator).



I find the formulas easier to work with when I write $phi$ for latitude
and $lambda$ for longitude.
Given your initial latitude $phi_1$ and longitude $lambda_1$ and the bearing $b$ toward the desired point at latitude $phi_2,$
let
$$
a = fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$
and compute the longitude $lambda_0$ at which the latitude of the great circle is maximized as follows:
$$
lambda_0 = lambda_1 pm arccosleft( fractan phi_1a right).
$$
You can determine the sign to use for $pm$ by considering the quadrant in which the angle $b$ lies.
For example, if $0 < b < 90^circ,$ then your general direction of travel along the circle is eastward and the maximum latitude is less than halfway around the circle in your direction of travel, so you take the $+$ sign.



Finally, let
$$
lambda_2
= lambda_0 pm arccosleft( fractan phi_2a right),
$$
using the angle $b$ and the direction from $phi_1$ to $phi_2$ to determine which sign to use for $pm.$
For example, if $0 < b < 90^circ$ and $phi_2 > phi_1,$ then you are traveling generally eastward but will reach latitude $phi_2$ before
$phi_max,$ so you should use the $-$ sign.




Here is a derivation of the formulas.



We have Clairaut's formula,
$$
sin psi cos phi = textconstant,
$$
where $psi$ is the bearing along the great circle at a point at
latitude $phi,$
and the implicit equation of a great circle,
$$
tan phi = a cos(lambda - lambda_0),
$$
where $phi$ and $lambda$ are the latitude and longitude of a point on the circle and where $a$ and $lambda_0$ are constants.
(See this question
but convert the latitude to your convention).



At the minimum and maximum latitudes of a great circle, the course is
$90^circ$ or $270^circ,$ so the absolute value of the constant in Clairaut's formula is $cos phi_max,$ where $phi_max$ is the maximum latitude of the great circle.
Plugging in your initial latitude $phi_1$ and your bearing $b,$
$$ cosphi_max = lvert sin b cos phi_1rvert. $$
From the identity $tanalpha = fracsqrt1 - cos^2alphacosalpha,$
we conclude that
$$
tan phi_max
= fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$



In the implicit equation, $a$ is the maximum value of the right-hand side,
while the left-hand side is maximized when $phi = phi_max,$ so
$$a = tanphi_max.$$
Moreover, $lambda_0$ is the longitude at which the maximum latitude is reached.
Plugging in your initial conditions,
$$
tan phi_1 = a cos(lambda_1 - lambda_0),
$$
where $lambda_1$ is your initial longitude.
It follows that
$$
cos(lambda_1 - lambda_0) = fractan phi_1a
$$
and that
$$
lambda_0
= lambda_1 pm arccosleft( fractan phi_1a right).
$$



Now that we know $a$ and $lambda_0,$ we can solve for $lambda_2$ in the equation
$$
tan phi_2 = tan phi_max cos(lambda_2 - lambda_0).
$$
The result is shown in the first part of this answer.




Having worked through all of that, I might still be inclined to transfer to Cartesian coordinates in order to do the work.
It is simple enough to find unit vectors pointing due north and due east along the surface of the Earth at any latitude and longitude, and from those and the bearing along a great circle through that point, get a vector perpendicular to the great circle.
If the coordinates of that vector are $(x_0,y_0,z_0),$
then $lambda_0 = textatan2(y_0, x_0).$
You can then get the angle $lvertlambda_2 - lambda_0rvert$
by constructing some right triangles and applying a little trig.



It's also possible to solve for $lambda_2$ in the formula in the question,
but it seems uglier to do it that way.






share|cite|improve this answer













I notice that your formula measures latitude up and down from the equator
(the geographer's convention) rather than down from the pole
(the mathematical convention).
Let's use your convention (relative to the equator).



I find the formulas easier to work with when I write $phi$ for latitude
and $lambda$ for longitude.
Given your initial latitude $phi_1$ and longitude $lambda_1$ and the bearing $b$ toward the desired point at latitude $phi_2,$
let
$$
a = fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$
and compute the longitude $lambda_0$ at which the latitude of the great circle is maximized as follows:
$$
lambda_0 = lambda_1 pm arccosleft( fractan phi_1a right).
$$
You can determine the sign to use for $pm$ by considering the quadrant in which the angle $b$ lies.
For example, if $0 < b < 90^circ,$ then your general direction of travel along the circle is eastward and the maximum latitude is less than halfway around the circle in your direction of travel, so you take the $+$ sign.



Finally, let
$$
lambda_2
= lambda_0 pm arccosleft( fractan phi_2a right),
$$
using the angle $b$ and the direction from $phi_1$ to $phi_2$ to determine which sign to use for $pm.$
For example, if $0 < b < 90^circ$ and $phi_2 > phi_1,$ then you are traveling generally eastward but will reach latitude $phi_2$ before
$phi_max,$ so you should use the $-$ sign.




Here is a derivation of the formulas.



We have Clairaut's formula,
$$
sin psi cos phi = textconstant,
$$
where $psi$ is the bearing along the great circle at a point at
latitude $phi,$
and the implicit equation of a great circle,
$$
tan phi = a cos(lambda - lambda_0),
$$
where $phi$ and $lambda$ are the latitude and longitude of a point on the circle and where $a$ and $lambda_0$ are constants.
(See this question
but convert the latitude to your convention).



At the minimum and maximum latitudes of a great circle, the course is
$90^circ$ or $270^circ,$ so the absolute value of the constant in Clairaut's formula is $cos phi_max,$ where $phi_max$ is the maximum latitude of the great circle.
Plugging in your initial latitude $phi_1$ and your bearing $b,$
$$ cosphi_max = lvert sin b cos phi_1rvert. $$
From the identity $tanalpha = fracsqrt1 - cos^2alphacosalpha,$
we conclude that
$$
tan phi_max
= fracsqrt1 - sin^2 b cos^2phi_1lvertsin b cosphi_1rvert
$$



In the implicit equation, $a$ is the maximum value of the right-hand side,
while the left-hand side is maximized when $phi = phi_max,$ so
$$a = tanphi_max.$$
Moreover, $lambda_0$ is the longitude at which the maximum latitude is reached.
Plugging in your initial conditions,
$$
tan phi_1 = a cos(lambda_1 - lambda_0),
$$
where $lambda_1$ is your initial longitude.
It follows that
$$
cos(lambda_1 - lambda_0) = fractan phi_1a
$$
and that
$$
lambda_0
= lambda_1 pm arccosleft( fractan phi_1a right).
$$



Now that we know $a$ and $lambda_0,$ we can solve for $lambda_2$ in the equation
$$
tan phi_2 = tan phi_max cos(lambda_2 - lambda_0).
$$
The result is shown in the first part of this answer.




Having worked through all of that, I might still be inclined to transfer to Cartesian coordinates in order to do the work.
It is simple enough to find unit vectors pointing due north and due east along the surface of the Earth at any latitude and longitude, and from those and the bearing along a great circle through that point, get a vector perpendicular to the great circle.
If the coordinates of that vector are $(x_0,y_0,z_0),$
then $lambda_0 = textatan2(y_0, x_0).$
You can then get the angle $lvertlambda_2 - lambda_0rvert$
by constructing some right triangles and applying a little trig.



It's also possible to solve for $lambda_2$ in the formula in the question,
but it seems uglier to do it that way.







share|cite|improve this answer













share|cite|improve this answer



share|cite|improve this answer











answered Jul 26 at 2:49









David K

48.1k340107




48.1k340107











  • Hi David, thanks for the answer. Do I use degree values or radians?
    – Mapster
    Jul 26 at 17:04










  • Most software libraries want the arguments of their trig functions to be in radians. That should be in the software documentation. If in doubt, try computing something like $cos(pi),$ which should be $-1$ if $pi$ is in radians. If you somehow have a "cosine" function that expects degrees, then $cos(pi)$ will be a little less than $1.$
    – David K
    Jul 26 at 17:12










  • I was trying to implement the answer to my solution. In my case I added 2 knows coordinates; $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$. I tried to find $phi_3$ when $lambda_3$ is 180 which will be $pi$. So $$phi_1 = 0.72161510588331557 , lambda_1 = 0.038397243543875255 and phi_2 = 0.71462506222907829, lambda_2 = 0.71462506222907829 $$ , and my bearing $$ b = 1.5908821682714704 $$. I tried to find $phi_3$ but ended up with negative value $$ phi_3 = -41.291340055344634$$ which it shouldn't be. I used every value in radians then converted it to degrees at the end.
    – Mapster
    Jul 26 at 17:48











  • I calculated the rhumb line bearing in radians between $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$
    – Mapster
    Jul 26 at 17:59










  • Actually, if you have one point on the great circle at $phi_1approx 0.7216, lambda_1 approx 0.0384,$ then I would expect the circle also to pass through a point with coordinates $phiapprox-0.7216,lambdaapproxpi+0.0384,$ exactly halfway around the circle. And that would come out to about $-41$ degrees latitude. Your point $phi_3,lambda_3$ would be close to that point on the great circle as well. So if the $phi_3$ you showed is in degrees, it looks just about right.
    – David K
    Jul 26 at 21:07

















  • Hi David, thanks for the answer. Do I use degree values or radians?
    – Mapster
    Jul 26 at 17:04










  • Most software libraries want the arguments of their trig functions to be in radians. That should be in the software documentation. If in doubt, try computing something like $cos(pi),$ which should be $-1$ if $pi$ is in radians. If you somehow have a "cosine" function that expects degrees, then $cos(pi)$ will be a little less than $1.$
    – David K
    Jul 26 at 17:12










  • I was trying to implement the answer to my solution. In my case I added 2 knows coordinates; $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$. I tried to find $phi_3$ when $lambda_3$ is 180 which will be $pi$. So $$phi_1 = 0.72161510588331557 , lambda_1 = 0.038397243543875255 and phi_2 = 0.71462506222907829, lambda_2 = 0.71462506222907829 $$ , and my bearing $$ b = 1.5908821682714704 $$. I tried to find $phi_3$ but ended up with negative value $$ phi_3 = -41.291340055344634$$ which it shouldn't be. I used every value in radians then converted it to degrees at the end.
    – Mapster
    Jul 26 at 17:48











  • I calculated the rhumb line bearing in radians between $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$
    – Mapster
    Jul 26 at 17:59










  • Actually, if you have one point on the great circle at $phi_1approx 0.7216, lambda_1 approx 0.0384,$ then I would expect the circle also to pass through a point with coordinates $phiapprox-0.7216,lambdaapproxpi+0.0384,$ exactly halfway around the circle. And that would come out to about $-41$ degrees latitude. Your point $phi_3,lambda_3$ would be close to that point on the great circle as well. So if the $phi_3$ you showed is in degrees, it looks just about right.
    – David K
    Jul 26 at 21:07
















Hi David, thanks for the answer. Do I use degree values or radians?
– Mapster
Jul 26 at 17:04




Hi David, thanks for the answer. Do I use degree values or radians?
– Mapster
Jul 26 at 17:04












Most software libraries want the arguments of their trig functions to be in radians. That should be in the software documentation. If in doubt, try computing something like $cos(pi),$ which should be $-1$ if $pi$ is in radians. If you somehow have a "cosine" function that expects degrees, then $cos(pi)$ will be a little less than $1.$
– David K
Jul 26 at 17:12




Most software libraries want the arguments of their trig functions to be in radians. That should be in the software documentation. If in doubt, try computing something like $cos(pi),$ which should be $-1$ if $pi$ is in radians. If you somehow have a "cosine" function that expects degrees, then $cos(pi)$ will be a little less than $1.$
– David K
Jul 26 at 17:12












I was trying to implement the answer to my solution. In my case I added 2 knows coordinates; $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$. I tried to find $phi_3$ when $lambda_3$ is 180 which will be $pi$. So $$phi_1 = 0.72161510588331557 , lambda_1 = 0.038397243543875255 and phi_2 = 0.71462506222907829, lambda_2 = 0.71462506222907829 $$ , and my bearing $$ b = 1.5908821682714704 $$. I tried to find $phi_3$ but ended up with negative value $$ phi_3 = -41.291340055344634$$ which it shouldn't be. I used every value in radians then converted it to degrees at the end.
– Mapster
Jul 26 at 17:48





I was trying to implement the answer to my solution. In my case I added 2 knows coordinates; $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$. I tried to find $phi_3$ when $lambda_3$ is 180 which will be $pi$. So $$phi_1 = 0.72161510588331557 , lambda_1 = 0.038397243543875255 and phi_2 = 0.71462506222907829, lambda_2 = 0.71462506222907829 $$ , and my bearing $$ b = 1.5908821682714704 $$. I tried to find $phi_3$ but ended up with negative value $$ phi_3 = -41.291340055344634$$ which it shouldn't be. I used every value in radians then converted it to degrees at the end.
– Mapster
Jul 26 at 17:48













I calculated the rhumb line bearing in radians between $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$
– Mapster
Jul 26 at 17:59




I calculated the rhumb line bearing in radians between $phi_1$, $lambda_1$ and $phi_2$, $lambda_2$
– Mapster
Jul 26 at 17:59












Actually, if you have one point on the great circle at $phi_1approx 0.7216, lambda_1 approx 0.0384,$ then I would expect the circle also to pass through a point with coordinates $phiapprox-0.7216,lambdaapproxpi+0.0384,$ exactly halfway around the circle. And that would come out to about $-41$ degrees latitude. Your point $phi_3,lambda_3$ would be close to that point on the great circle as well. So if the $phi_3$ you showed is in degrees, it looks just about right.
– David K
Jul 26 at 21:07





Actually, if you have one point on the great circle at $phi_1approx 0.7216, lambda_1 approx 0.0384,$ then I would expect the circle also to pass through a point with coordinates $phiapprox-0.7216,lambdaapproxpi+0.0384,$ exactly halfway around the circle. And that would come out to about $-41$ degrees latitude. Your point $phi_3,lambda_3$ would be close to that point on the great circle as well. So if the $phi_3$ you showed is in degrees, it looks just about right.
– David K
Jul 26 at 21:07













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2862455%2fpull-constant-from-atan2-function%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Color the edges and diagonals of a regular polygon

Relationship between determinant of matrix and determinant of adjoint?

What is the equation of a 3D cone with generalised tilt?