开发者

Math.Asin problem

开发者 https://www.devze.com 2023-02-09 05:29 出处:网络
I am calculating a value ( that should reflect the sin of an angle between a direction vector and the XZ plane ) like this

I am calculating a value ( that should reflect the sin of an angle between a direction vector and the XZ plane ) like this

angle_between_direction_and_Xplane = (Math.Abs(enemyShip_.orientation.Forward.Y) /  Math.Sqrt(Math.Pow(enemyShip_.orientation.Forward.X, 2) + Math.Pow(enemyShip_.orientation.Forward.Y, 2) + Math.Pow(enemyShip_.orientation.Forward.Z, 2)))开发者_运维问答;

and it seems to work just fine . When the object is perpendicular to the ground the angle_between_direction_and_Xplane is near to 1 and when it is paralel to XZ plane it is near to 0 .

When i apply Math.Asin i would like to get a angle ( like 70 or 20 degrees ) but instead i get values around 1 . Am I using it wrong ?


Asin returns the angle in radians. Multiply with 180/pi to get the angle in degrees.


Sounds like you're forgetting that math libraries use radians for angles, not degrees. Apply the appropriate conversion and see if that matches your intuition better.

0

精彩评论

暂无评论...
验证码 换一张
取 消