Angles between 3D vectors in groups
Mostrar comentarios más antiguos
So I understand that in order to return an angle between two vectors a and b, this code should be used:
angle = atan2d(norm(.cross(a,b),.dot(a,b)));
However, I have vectors in groups (in one variable), and I'd like to be able to perform this as well. Let me clarify, suppose it looks like this:
A = rand(3,10);
B = rand(3,10);
%both the variables have 3*10 elements, but actually they are a total of 10 coordinates(x,y,z)
%where 1st row are all x values, 2nd row y values and last row z values;
%thus for example 1st column of A stands for the first point of A, and etc;
Is there a way to calculate, in groups, the angles between 1st columns of A and B, 2nd columns of A and B, ..., and 10th columns of A and B? The result I'm looking for may need to be a 1*10 variable.
(My thought is to reshape the variables A and B to make it more calculable, but wasn't sure how; or, to create a loop that repeats the calculation for each columns?)
Thanks in advanced,
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!