Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
12
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@vkgtaro

ベクトルの角度を求める

三角関数とかもう覚えてないわーってことでメモ。
原点から x, y の座標へのベクトルが x 軸から何度あるのか求めるのを javascript で。
(chrome の console で気軽に求められるので)

calculate_cosine = function (x, y) { return x / Math.sqrt(x*x + y*y); };
calculate_radian = function (cos) { return Math.acos(cos) / (Math.PI / 180); };

座標 x = 50, y = 20 のときはこうなる。

> calculate_radian( calculate_cosine(50, 20) );
21.80140948635181
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
12
Help us understand the problem. What are the problem?