gpt4 book ai didi

c++ - 二维单位 vector 的角度?

转载 作者:IT老高 更新时间:2023-10-28 12:58:34 26 4
gpt4 key购买 nike

给定单位 vector (0.5, 0.5) 我怎么能找到角度(它的方向)?

cos(x) + sin(y)吗?

最佳答案

给定 y 和 x,与 x 轴的夹角由下式给出:

atan2(y, x) // note that Y is first

使用 (0.5, 0.5) 时,角度为:

弧度:

In [2]: math.atan2(0.5, 0.5)
Out[2]: 0.7853981633974483

度数:

In [3]: math.atan2(0.5, 0.5)*180/math.pi
Out[3]: 45.0

关于c++ - 二维单位 vector 的角度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6247153/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com