how do i find the angle between a vector and a line?

Answers (1)

b = [2,5,8]; % vector along line
ang = atan2(norm(cross(a,b)),dot(a,b)); % Angle in radians between vectors a and b
(Note: If you take a vector b along the opposite direction along the line, the resulting angle will be the supplement of the above - that is, it will be pi minus the above angle. Which answer is correct depends on your definition of the angle between a vector and a line.)

Asked:

on 6 Nov 2014

Edited:

on 6 Nov 2014

Community Treasure Hunt

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

Start Hunting!