atan2 and Cardan angles - Problem with sign
up vote
0
down vote
favorite
I'd like to get the three Cardan angles starting from the below matrix and by using the function atan2. The problem is that I get two conflicting results.
where $- pi/2 le beta le pi/2$.
If I consider the case $x>0$ in the above Wikipedia's webpage, I'll get (I call $R_{ij}$ the elements of the matrix):
$$ tan(gamma) = -frac{R_{31}}{R_{33}} $$
and I can use one of these two $operatorname {atan2}.$
Case 1: $x=R_{33}>0$
$$ gamma = operatorname {atan2}(-R_{31},R_{33}) = arctan(tan(gamma)) = gamma $$
if $R_{33}>0$.
Case 2: $x=-R_{33}>0$
$$ gamma = operatorname {atan2}(R_{31},-R_{33}) = arctan(tan(gamma)) = gamma $$
if $-R_{33}>0$.
How it is possible to get the same result the first time when $R_{33}>0$, the second time when $-R_{33}>0$?
Maybe I can pass from $tan$ to $operatorname {atan2}$ only when there is no sign before the ratio between the numerator and the denominator of the right term $tan(text {angle})=dfrac {text {numerator}}{text {denominator}}$?
Thank you so much in advance.
trigonometry education classical-mechanics
|
show 1 more comment
up vote
0
down vote
favorite
I'd like to get the three Cardan angles starting from the below matrix and by using the function atan2. The problem is that I get two conflicting results.
where $- pi/2 le beta le pi/2$.
If I consider the case $x>0$ in the above Wikipedia's webpage, I'll get (I call $R_{ij}$ the elements of the matrix):
$$ tan(gamma) = -frac{R_{31}}{R_{33}} $$
and I can use one of these two $operatorname {atan2}.$
Case 1: $x=R_{33}>0$
$$ gamma = operatorname {atan2}(-R_{31},R_{33}) = arctan(tan(gamma)) = gamma $$
if $R_{33}>0$.
Case 2: $x=-R_{33}>0$
$$ gamma = operatorname {atan2}(R_{31},-R_{33}) = arctan(tan(gamma)) = gamma $$
if $-R_{33}>0$.
How it is possible to get the same result the first time when $R_{33}>0$, the second time when $-R_{33}>0$?
Maybe I can pass from $tan$ to $operatorname {atan2}$ only when there is no sign before the ratio between the numerator and the denominator of the right term $tan(text {angle})=dfrac {text {numerator}}{text {denominator}}$?
Thank you so much in advance.
trigonometry education classical-mechanics
1
As $cos beta>0$, you always have that $(cos γ,sinγ)sim (R_{33},-R_{31})$ so that always $γ=arg(R_{33}-iR_{31})=atan2(-R_{31},R_{33})$.
– LutzL
Nov 13 at 17:28
Hello @LutzL, can you tell me why you wrote $(cos γ,sinγ)sim (R_{33},-R_{31})$ instead of $(cos γ,-sinγ)sim (R_{33},-R_{31})$ please?
– Gennaro Arguzzi
Nov 13 at 17:39
1
Because there is only one sign to distribute. As I said, $cosβ>0$ and $(cosγ,sinγ)=(R_{33},−R_{31})/cosβ$. This defines the polar decomposition uniquely.
– LutzL
Nov 13 at 18:21
@LutzL thank you for your extremely clear explanation.
– Gennaro Arguzzi
Nov 13 at 18:23
1
1. So what do you find confusing here exactly? Why are you expecting different results in two chains of equalities that both start with $gamma$? As it is, it is unclear what you are asking. 2. How is $gamma$ defined, and what is its domain? You know that $arctan(tangamma)=gamma$ does not hold in general, right?
– Federico Poloni
Nov 13 at 19:02
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'd like to get the three Cardan angles starting from the below matrix and by using the function atan2. The problem is that I get two conflicting results.
where $- pi/2 le beta le pi/2$.
If I consider the case $x>0$ in the above Wikipedia's webpage, I'll get (I call $R_{ij}$ the elements of the matrix):
$$ tan(gamma) = -frac{R_{31}}{R_{33}} $$
and I can use one of these two $operatorname {atan2}.$
Case 1: $x=R_{33}>0$
$$ gamma = operatorname {atan2}(-R_{31},R_{33}) = arctan(tan(gamma)) = gamma $$
if $R_{33}>0$.
Case 2: $x=-R_{33}>0$
$$ gamma = operatorname {atan2}(R_{31},-R_{33}) = arctan(tan(gamma)) = gamma $$
if $-R_{33}>0$.
How it is possible to get the same result the first time when $R_{33}>0$, the second time when $-R_{33}>0$?
Maybe I can pass from $tan$ to $operatorname {atan2}$ only when there is no sign before the ratio between the numerator and the denominator of the right term $tan(text {angle})=dfrac {text {numerator}}{text {denominator}}$?
Thank you so much in advance.
trigonometry education classical-mechanics
I'd like to get the three Cardan angles starting from the below matrix and by using the function atan2. The problem is that I get two conflicting results.
where $- pi/2 le beta le pi/2$.
If I consider the case $x>0$ in the above Wikipedia's webpage, I'll get (I call $R_{ij}$ the elements of the matrix):
$$ tan(gamma) = -frac{R_{31}}{R_{33}} $$
and I can use one of these two $operatorname {atan2}.$
Case 1: $x=R_{33}>0$
$$ gamma = operatorname {atan2}(-R_{31},R_{33}) = arctan(tan(gamma)) = gamma $$
if $R_{33}>0$.
Case 2: $x=-R_{33}>0$
$$ gamma = operatorname {atan2}(R_{31},-R_{33}) = arctan(tan(gamma)) = gamma $$
if $-R_{33}>0$.
How it is possible to get the same result the first time when $R_{33}>0$, the second time when $-R_{33}>0$?
Maybe I can pass from $tan$ to $operatorname {atan2}$ only when there is no sign before the ratio between the numerator and the denominator of the right term $tan(text {angle})=dfrac {text {numerator}}{text {denominator}}$?
Thank you so much in advance.
trigonometry education classical-mechanics
trigonometry education classical-mechanics
edited Nov 14 at 0:28
bjcolby15
1,0961916
1,0961916
asked Nov 13 at 17:11
Gennaro Arguzzi
321313
321313
1
As $cos beta>0$, you always have that $(cos γ,sinγ)sim (R_{33},-R_{31})$ so that always $γ=arg(R_{33}-iR_{31})=atan2(-R_{31},R_{33})$.
– LutzL
Nov 13 at 17:28
Hello @LutzL, can you tell me why you wrote $(cos γ,sinγ)sim (R_{33},-R_{31})$ instead of $(cos γ,-sinγ)sim (R_{33},-R_{31})$ please?
– Gennaro Arguzzi
Nov 13 at 17:39
1
Because there is only one sign to distribute. As I said, $cosβ>0$ and $(cosγ,sinγ)=(R_{33},−R_{31})/cosβ$. This defines the polar decomposition uniquely.
– LutzL
Nov 13 at 18:21
@LutzL thank you for your extremely clear explanation.
– Gennaro Arguzzi
Nov 13 at 18:23
1
1. So what do you find confusing here exactly? Why are you expecting different results in two chains of equalities that both start with $gamma$? As it is, it is unclear what you are asking. 2. How is $gamma$ defined, and what is its domain? You know that $arctan(tangamma)=gamma$ does not hold in general, right?
– Federico Poloni
Nov 13 at 19:02
|
show 1 more comment
1
As $cos beta>0$, you always have that $(cos γ,sinγ)sim (R_{33},-R_{31})$ so that always $γ=arg(R_{33}-iR_{31})=atan2(-R_{31},R_{33})$.
– LutzL
Nov 13 at 17:28
Hello @LutzL, can you tell me why you wrote $(cos γ,sinγ)sim (R_{33},-R_{31})$ instead of $(cos γ,-sinγ)sim (R_{33},-R_{31})$ please?
– Gennaro Arguzzi
Nov 13 at 17:39
1
Because there is only one sign to distribute. As I said, $cosβ>0$ and $(cosγ,sinγ)=(R_{33},−R_{31})/cosβ$. This defines the polar decomposition uniquely.
– LutzL
Nov 13 at 18:21
@LutzL thank you for your extremely clear explanation.
– Gennaro Arguzzi
Nov 13 at 18:23
1
1. So what do you find confusing here exactly? Why are you expecting different results in two chains of equalities that both start with $gamma$? As it is, it is unclear what you are asking. 2. How is $gamma$ defined, and what is its domain? You know that $arctan(tangamma)=gamma$ does not hold in general, right?
– Federico Poloni
Nov 13 at 19:02
1
1
As $cos beta>0$, you always have that $(cos γ,sinγ)sim (R_{33},-R_{31})$ so that always $γ=arg(R_{33}-iR_{31})=atan2(-R_{31},R_{33})$.
– LutzL
Nov 13 at 17:28
As $cos beta>0$, you always have that $(cos γ,sinγ)sim (R_{33},-R_{31})$ so that always $γ=arg(R_{33}-iR_{31})=atan2(-R_{31},R_{33})$.
– LutzL
Nov 13 at 17:28
Hello @LutzL, can you tell me why you wrote $(cos γ,sinγ)sim (R_{33},-R_{31})$ instead of $(cos γ,-sinγ)sim (R_{33},-R_{31})$ please?
– Gennaro Arguzzi
Nov 13 at 17:39
Hello @LutzL, can you tell me why you wrote $(cos γ,sinγ)sim (R_{33},-R_{31})$ instead of $(cos γ,-sinγ)sim (R_{33},-R_{31})$ please?
– Gennaro Arguzzi
Nov 13 at 17:39
1
1
Because there is only one sign to distribute. As I said, $cosβ>0$ and $(cosγ,sinγ)=(R_{33},−R_{31})/cosβ$. This defines the polar decomposition uniquely.
– LutzL
Nov 13 at 18:21
Because there is only one sign to distribute. As I said, $cosβ>0$ and $(cosγ,sinγ)=(R_{33},−R_{31})/cosβ$. This defines the polar decomposition uniquely.
– LutzL
Nov 13 at 18:21
@LutzL thank you for your extremely clear explanation.
– Gennaro Arguzzi
Nov 13 at 18:23
@LutzL thank you for your extremely clear explanation.
– Gennaro Arguzzi
Nov 13 at 18:23
1
1
1. So what do you find confusing here exactly? Why are you expecting different results in two chains of equalities that both start with $gamma$? As it is, it is unclear what you are asking. 2. How is $gamma$ defined, and what is its domain? You know that $arctan(tangamma)=gamma$ does not hold in general, right?
– Federico Poloni
Nov 13 at 19:02
1. So what do you find confusing here exactly? Why are you expecting different results in two chains of equalities that both start with $gamma$? As it is, it is unclear what you are asking. 2. How is $gamma$ defined, and what is its domain? You know that $arctan(tangamma)=gamma$ does not hold in general, right?
– Federico Poloni
Nov 13 at 19:02
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
The ratio $frac{sin gamma}{cosgamma}$ does not specify an angle $-pi < gamma leq pi$ uniquely, but only up to $pi$; to specify it, you need two coordinates $x,y$, not both zero, through which the variable side of the angle passes: that's the whole idea behind atan2
and you should make sure you are familiar with it before tackling these computations.
In your case, you have restricted to $-fracpi2 < gamma < fracpi2$, which means that your angle is in the right half-plane, so these coordinates have $x>0$. Focus on the first equal sign in each of those two alternative computations: only one of them is correct, the one with $cosgamma > 0$. To know which one it is, you will have to know the sign of $cos beta$ as well.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
The ratio $frac{sin gamma}{cosgamma}$ does not specify an angle $-pi < gamma leq pi$ uniquely, but only up to $pi$; to specify it, you need two coordinates $x,y$, not both zero, through which the variable side of the angle passes: that's the whole idea behind atan2
and you should make sure you are familiar with it before tackling these computations.
In your case, you have restricted to $-fracpi2 < gamma < fracpi2$, which means that your angle is in the right half-plane, so these coordinates have $x>0$. Focus on the first equal sign in each of those two alternative computations: only one of them is correct, the one with $cosgamma > 0$. To know which one it is, you will have to know the sign of $cos beta$ as well.
add a comment |
up vote
2
down vote
accepted
The ratio $frac{sin gamma}{cosgamma}$ does not specify an angle $-pi < gamma leq pi$ uniquely, but only up to $pi$; to specify it, you need two coordinates $x,y$, not both zero, through which the variable side of the angle passes: that's the whole idea behind atan2
and you should make sure you are familiar with it before tackling these computations.
In your case, you have restricted to $-fracpi2 < gamma < fracpi2$, which means that your angle is in the right half-plane, so these coordinates have $x>0$. Focus on the first equal sign in each of those two alternative computations: only one of them is correct, the one with $cosgamma > 0$. To know which one it is, you will have to know the sign of $cos beta$ as well.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
The ratio $frac{sin gamma}{cosgamma}$ does not specify an angle $-pi < gamma leq pi$ uniquely, but only up to $pi$; to specify it, you need two coordinates $x,y$, not both zero, through which the variable side of the angle passes: that's the whole idea behind atan2
and you should make sure you are familiar with it before tackling these computations.
In your case, you have restricted to $-fracpi2 < gamma < fracpi2$, which means that your angle is in the right half-plane, so these coordinates have $x>0$. Focus on the first equal sign in each of those two alternative computations: only one of them is correct, the one with $cosgamma > 0$. To know which one it is, you will have to know the sign of $cos beta$ as well.
The ratio $frac{sin gamma}{cosgamma}$ does not specify an angle $-pi < gamma leq pi$ uniquely, but only up to $pi$; to specify it, you need two coordinates $x,y$, not both zero, through which the variable side of the angle passes: that's the whole idea behind atan2
and you should make sure you are familiar with it before tackling these computations.
In your case, you have restricted to $-fracpi2 < gamma < fracpi2$, which means that your angle is in the right half-plane, so these coordinates have $x>0$. Focus on the first equal sign in each of those two alternative computations: only one of them is correct, the one with $cosgamma > 0$. To know which one it is, you will have to know the sign of $cos beta$ as well.
answered Nov 14 at 7:32
Federico Poloni
2,4631327
2,4631327
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2997004%2fatan2-and-cardan-angles-problem-with-sign%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
As $cos beta>0$, you always have that $(cos γ,sinγ)sim (R_{33},-R_{31})$ so that always $γ=arg(R_{33}-iR_{31})=atan2(-R_{31},R_{33})$.
– LutzL
Nov 13 at 17:28
Hello @LutzL, can you tell me why you wrote $(cos γ,sinγ)sim (R_{33},-R_{31})$ instead of $(cos γ,-sinγ)sim (R_{33},-R_{31})$ please?
– Gennaro Arguzzi
Nov 13 at 17:39
1
Because there is only one sign to distribute. As I said, $cosβ>0$ and $(cosγ,sinγ)=(R_{33},−R_{31})/cosβ$. This defines the polar decomposition uniquely.
– LutzL
Nov 13 at 18:21
@LutzL thank you for your extremely clear explanation.
– Gennaro Arguzzi
Nov 13 at 18:23
1
1. So what do you find confusing here exactly? Why are you expecting different results in two chains of equalities that both start with $gamma$? As it is, it is unclear what you are asking. 2. How is $gamma$ defined, and what is its domain? You know that $arctan(tangamma)=gamma$ does not hold in general, right?
– Federico Poloni
Nov 13 at 19:02