本文介绍了反之math.atan2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数的逆是什么

math.atan2

我在Lua中使用它,在这里我可以得到math.tanmath.atan的逆.
但是我在这里迷路了.

I use this in Lua where I can get the inverse of math.atan by math.tan.
But I am lost here.

编辑

好的,让我给您提供更多细节.

OK, let me give you more details.

我需要计算2个点(x1,y1)和(x2,y2)之间的夹角,

I needed to calculate angle between 2 points (x1,y1) and (x2,y2) and I did,

local dy = y1-y2
local dx = x1-x2
local angle = atan2(dy,dx)* 180 / pi

现在,如果我有角度,是否有可能使dy和dx恢复原状?

Now if I have the angle, is it possible to get back dy and dx?

推荐答案

仅给出角度,您只能导出指向(dx, dy)的单位矢量.要获得原始的(dx, dy),您还需要知道向量(dx, dy)的长​​度,我将其称为len.您还必须将从度数得出的角度转换回弧度,然后使用本文其他地方提到的trig方程.那就是你有

Given only the angle you can only derive a unit vector pointing to (dx, dy). To get the original (dx, dy) you also need to know the length of the vector (dx, dy), which I'll call len. You also have to convert the angle you derived from degrees back to radians and then use the trig equations mentioned elsewhere in this post. That is you have:

local dy = y1-y2
local dx = x1-x2
local angle = atan2(dy,dx) * 180 / pi
local len = sqrt(dx*dx + dy*dy)

给出angle(以度为单位)和向量长度len,您可以通过以下方式得出dxdy:

Given angle (in degrees) and the vector length, len, you can derive dx and dy by:

local theta = angle * pi / 180
local dx = len * cos(theta)
local dy = len * sin(theta)

这篇关于反之math.atan2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 06:25