1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

自分メモ用 2つのベクトルの角度を求めるソースコード

Last updated at Posted at 2018-03-18
static float Angle(3DVector A,3DVector B)//適宜3Dvectorを必要に応じて変更する
{
    float dot=((A.x*B.x)+(A.y*B.y)+(A.z*B.z));
    float magnitude=((A.x*A.x)+(A.y*A.y)+(A.z*A.z))*((B.x*B.x)+(B.y*B.y)+(B.z*B.z))
    float cos=dot/magnitude;
    float acos =Acos(cos);//ここも必要に応じて変更する
    float angle =acos*180/3.14
//度に変換すること

    return angle;
}
1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?