フィルターのクリア

3D Matrix Multiplication using a Series

6 ビュー (過去 30 日間)
Mark Dawson
Mark Dawson 2020 年 10 月 18 日
コメント済み: Ameer Hamza 2020 年 10 月 18 日
So I've got an issue in regards to multiplying out 3 4x4 matricies that i need to obtain my final transformation matrix. They're contained within a 4 x 4 x 3 matirx, as three distinct 4 x 4 "slices". The 3D matrix is probably the neatest way i can store the data, the numeric data is obained from a few arbitrary functions, for all intents and purposes, assume its just random numbers.
So i need to multiply them out to obtain "T" my overal transforation matrix, but for the sake of making my program more versatile I cant merely multiply out the slices. I need to do it as part of a series, say use N, for a 4 x 4 x N matrix. I.e. I kinda want my program to be universal.
Edit: I shouls add, it's required for the 4 x 4 matricies to be multiplied in order, i.e. Ast(:,:,n)*Ast(:,:,n+1)*...*Ast(:,:,n+m)
% 4 x 4 Homogeneous Translation Matricies
TransX = @(a)[1 0 0 a; 0 1 0 0; 0 0 1 0; 0 0 0 1];
TransY = @(b)[1 0 0 0; 0 1 0 b; 0 0 1 0; 0 0 0 1];
TransZ = @(c)[1 0 0 0; 0 1 0 0; 0 0 1 c; 0 0 0 1];
% 4 x 4 Homogeneous Rotational Matricies
RotX =@(theta)[1 0 0 0; 0 cos(theta) -sin(theta) 0; 0 sin(theta) cos(theta) 0; 0 0 0 1];
RotY =@(theta)[cos(theta) 0 sin(theta) 0; 0 1 0 0; -sin(theta) 0 cos(theta) 0; 0 0 0 1];
RotZ =@(theta)[cos(theta) -sin(theta) 0 0; sin(theta) cos(theta) 0 0; 0 0 1 0; 0 0 0 1];
%%%%%%%%%%%%%%%%%%%Physical System Parameters%%%%%%%%%%%%%%%%%%%%
%Link Numbers - Kinda Important for Making application more universal
n = 3;
%Denevit Hartenberg 'Table'
%User Can set these to whatever, but must be n entries
a= [2,3,4];
alpha = [0,0,0];
d = [0,0,0];
theta_l = [pi/12,pi/12,pi/12];
theta = cumsum(theta_l);
%Anonymous Numeric Denavit Hartenberg Function
A=@(a_i,alpha_i,d_i,theta_i)RotZ(theta_i)*TransZ(d_i)*TransX (a_i)*RotX(alpha_i);
A_i= @(i)A(a(i),alpha(i),d(i),theta(i));
%Create 4 x 4 x n 3D Transformation Matricies
for j = [1:1:n]
Ast(:,:,j)= A_i(j);
end
%Overall Transformation Matrix
T = Ast(:,:,1)*Ast(:,:,2)*Ast(:,:,3);

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 18 日
A for-loop might be the simpliest solution
A = rand(4,4,10);
n = 2;
m = 4;
A_result = eye(size(A,1));
for i = n:n+m
A_result = A_result*A(:,:,i);
end
  2 件のコメント
Mark Dawson
Mark Dawson 2020 年 10 月 18 日
Thats it, thanks man.
Ameer Hamza
Ameer Hamza 2020 年 10 月 18 日
I am glad to be of help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by