What would the angles be for a 3D vector?

13 ビュー (過去 30 日間)
Nathan
Nathan 2013 年 12 月 6 日
回答済み: Roger Stafford 2013 年 12 月 6 日
Hi, I've got a vector with components, x, y and z. I need to know the x, y and z angles for that vector.
I assume that the x-angle would be atand(max(y)/max(x))) and I also assume that the y-angle is 90-x.
Would those be correct for a 3D vectors definition of a x and y angle? Also, how do I calculate the z-angle?

回答 (1 件)

Roger Stafford
Roger Stafford 2013 年 12 月 6 日
Let x, y, and z be the vectors' three components. The angle the vector makes relative to the positive x-axis can be computed as:
ax = atan2(sqrt(y^2+z^2),x);
Similarly ay and az, the angles with respect to the y and z axes, are given by:
ay = atan2(sqrt(z^2+x^2),y);
az = atan2(sqrt(x^2+y^2),z);
These are somewhat more accurate than using the ax = acos(x/sqrt(x^2+y^2+z^2)) type formula. Note that the resulting angles are in radians.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by