Matrix multiplication between an operation matrix, such as the rotation matrix, and a coordinate list.
Show older comments
Hi
I would like to apply a 3D rotation operation, by matrix multiplication, on each of a element (rows) of coordinate list represented by a N x 3 vector.
For now I use a for-loop over all coordinates, see below, but I would prefer to do this in one operation.
BR
Thomas
y_rotation_matrix=@(theta) [cos(-theta) 0 sin(-theta);0 1 0;-sin(-theta) 0 cos(-theta)];
coordinate_list=rand(10,3)
hold on
xlabel('x')
ylabel('y')
zlabel('z')
plot3(coordinate_list(:,1),coordinate_list(:,2),coordinate_list(:,3));
rotated_coordinate_list=nan(size(coordinate_list));
theta0=.3
for q=1:size(coordinate_list,1)
rotated_coordinate_list(q,:)=y_rotation_matrix(theta0)*coordinate_list(q,:)';
end
plot3(rotated_coordinate_list(:,1),rotated_coordinate_list(:,2),rotated_coordinate_list(:,3));
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!