如何从矩阵中获取角度 [英] How can I get the angle from a matrix

查看:385
本文介绍了如何从矩阵中获取角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的旋转矩阵:

I got a rotation matrix like this:

1.0       0.0        0.0        2.07814
0.0      -0.809017   0.587785   0.0
0.0      -0.587785  -0.809017   0.0
0.0       0.0        0.0        1.0

我如何从中得到角度?如果我应用逆函数,我会得到这个

How can i get the angle from this? If I apply the inverse, i get this

cos exp -1 (-0.809017) = 144.0
sin exp -1 (-0.587785) = -36.0
sin exp -1 ( 0.587785) =  36.0
cos exp -1 (-0.809017) = 144.0

但是我的问题是我知道该角度为216.0度,如何恢复该角度?

But my problem is I know that the angle was 216.0 degrees, How do I get back that angle?

推荐答案

我认为您正在错误地计算反函数 ,这让我感到奇怪.您应将asin用于反正弦,将acos用于反余弦.您正在计算乘性逆,而不是功能逆.尽管在这里,这似乎是同一回事.

I think you're computing inverse functions incorrectly in a manner that struck me as bizarre. You should use asin for the inverse sin and acos for the inverse cos. You're computing the multiplicative inverse, not the functional inverse. Although here, it appears to be the same thing.

使用atan2()功能.它将根据y和x值得出角度.它隐式计算反正弦和反余弦,并检查y和x的符号以发现正确的象限.

Use the atan2() function. It will yield the angle from the y and x values. It implicitly computes the inverse sin and inverse cos, and it checks the signs of both y and x to discover the correct quadrant.

 ATAN2(3)

NAME
       1.8 `atan2', `atan2f'--arc tangent of y/x

SYNOPSIS
            #include 
            double atan2(double Y,double X);
            float atan2f(float Y,float X);

DESCRIPTION
       `atan2'  computes  the  inverse tangent (arc tangent) of Y/X.  `atan2' 
       produces the correct result even for angles near pi/2 or -pi/2 (that
       is, when X is near 0).

          `atan2f' is identical to `atan2', save that it takes and returns `float'.

RETURNS
       `atan2' and `atan2f' return a value in radians, in the range of -pi to pi.

我认为我们忽略了2.07814显然不是轮换的一部分. atan2(0.587785, -0.809017)给我144.0度. atan(-0.587785, -0.809017)给出216.0.

I assume we're ignoring that 2.07814 that's clearly not part of the rotation. atan2(0.587785, -0.809017) gives me 144.0 degrees. atan(-0.587785, -0.809017) gives 216.0.


啊哈!您的矩阵与我习惯的横向".我认为2.07814部分只是翻译.以此3d旋转矩阵为指导,


Aha! Your matrix is "sideways" from what I'm used to. The 2.07814 part is just a translation, I think. Using this 3d rotation matrix as a guide,

1  0   0
0  cos sin
0 -sin cos

...让我像以前一样困惑.我不断得到144.0.

... leaves me just as confused as before. I keep getting 144.0.

坦白.

我对上面的弧度/度问题不屑一顾,因为我使用了Postscript而不是C.

I glossed over the radians/degrees issue above, because I used Postscript instead of C.

$ gsnd -q
GS>0.587785 -0.809017 atan =
144.0
GS>-0.587785 -0.809017 atan =
216.0
GS>

这篇关于如何从矩阵中获取角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆