Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Computing Angle between Three Dimensional Vectors

$
0
0
"Dan" wrote in message <knndc0$mcd$1@newscl01ah.mathworks.com>...
> Good morning all,
>
> I've been search for a solution to my problem. I am trying to compute the angle between 3 three dimensional vectors (XYZ) with the following format:
>
> v1 = -0.1667 0.2992 2.6620
> v2 = -0.1556 0.2767 2.6856
> v3 = -0.1570 0.2682 2.7318
>
> I'd like to know the angle from the origin of v2. I am currently using the following sequence of commands:-
>
> angle = atan2(norm(cross(v1, v2, v3)), dot(v1, v2, v2));
>
> However it throws a size error - Dimensions argument must be a positive integer wihin indexing range.
>
> My question is two-fold:
>
> a) How do I solve the current error message being throw by Matlab
> b) If the function correct in computing the angle with the centre being v2
>
> Thanks for your time and help.
>
> Dan

I've been exploring and I'd like to know if the following flow is correct (if possible)


With v2 being the centre point and the angle needing to be determined:

v1 = -(x2-x1, y2-y1, z2-z1)
v3 = (x3-x2, y3-y2, z3-z2)

Normalisation being performed

n1 = v1 / norm(v1)
n3 = v3 / norm(v3)

radius = acos( dot(n1, n3) )
 
angle = pi - radius

Regards,

Dan

Viewing all articles
Browse latest Browse all 19628

Latest Images

Trending Articles



Latest Images