本文介绍了从sin/cos转换中找回角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想反转sin/cos操作以恢复角度,但是我不知道该怎么做.

I want to reverse a sin/cos operation to get back an angle, but I can't figure out what I should be doing.

我以弧度为角度使用sincos来获取x/y向量,如下所示:

I have used sin and cos on an angle in radians to get the x/y vector as such:

double angle = 90.0 * M_PI / 180.0;  // 90 deg. to rad.
double s_x = cos( angle );
double s_y = sin( angle );

给出s_xs_y,是否可以找回角度?我以为atan2是要使用的函数,但没有得到预期的结果.

Given s_x and s_y, is it possible to get back the angle? I thought atan2 was the function to use, but I'm not getting the expected results.

推荐答案

atan2(s_y, s_x)应该给您正确的角度.也许您已经颠倒了s_xs_y的顺序.另外,您可以分别在s_xs_y上直接使用acosasin函数.

atan2(s_y, s_x) should give you the correct angle. Maybe you have reversed the order of s_x and s_y. Also, you can use the acos and asin functions directly on s_x and s_y respectively.

这篇关于从sin/cos转换中找回角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 22:10