- 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
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Dev
on 30 May 2025
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 Comments
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!