- X-axis: u = [1, 0] or [1, 0, 0]
- Y-axis: u = [0, 1] or [0, 1, 0]
- Z-axis: u = [0, 0, 1] (for 3D)
finding the angle between a line and oblique axis
6 ビュー (過去 30 日間)
古いコメントを表示
is there any way to find the angle between a line (vector) and its coressponding axis. I don't want to rotate to x-axis and work from there.
please refer to the attached image.
0 件のコメント
回答 (1 件)
Dev
2025 年 5 月 30 日
We can compute the angle between a vector and an axis (X, Y or Z) directly without rotating any of the axes, using the dot product formula.
Given a vector v = [vx, vy] or [vx, vy, vz], and an axis unit vector:
The angle between vector ‘v’ and axis ‘u’ can be calculate as follows-
Θ = cos−1(v*u/∥v∥*∥u∥ )
We can compute the same using the “dot” and “acos” functions available in MATLAB. I have attached a reference code snippet below which achieves the same.
% Compute angle
cosTheta = dot(v, u) / (norm(v) * norm(u));
angleRad = acos(cosTheta);
angleDeg = rad2deg(angleRad); % since acos returns angle in Radians
For more information regarding these functions, please refer to the documentation links using the below commands in your MATLAB terminal-
>> doc dot
>> doc acos
I hope the above explanation helps.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!