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;
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme