function [M1L,M2L,M3L,M4L,M5L,M5R,M4R,M3R] = calculo_torque(Pf,Pf1)

M1L = 0;
M2L = 0;
M3L = 0;
M4L = 0;
M5L = 0;
M5R = 0;
M4R = 0;
M3R = 0;


% DETERMINAÇLAO DOS TORQUES E DOS CENTROS DE MASSA PARA AS DIFERENTES JUNTAS:
% Dados:
m1 = 0.75;
m2 = 0.75;
m3 = 5.5;
g = 9.81;

% Determinaçao dos centros de massa dos elos:
CM = (Pf(:,2:11)-Pf(:,1:10))/2;
CM3 = (Pf(:,5)+Pf1(:,7))/2;
CMTotal = [CM(:,2) CM(:,3) CM3(:,1) CM(:,7) CM(:,8)];

% Determinaçao das coordenadas centro de massa total
CMJunta12 = ((m1*(CMTotal(:,1)+CMTotal(:,5))+m2*(CMTotal(:,2)+CMTotal(:,4))+m3*(CMTotal(:,3)))/(m1+m2+m3));
CMJunta3 = ((m1*CMTotal(:,5)+m2*(CMTotal(:,2)+CMTotal(:,4))+m3*(CMTotal(:,3)))/(m1+m2+m3));
CMJunta45 = ((m1*CMTotal(:,5)+m2*(CMTotal(:,4))+m3*(CMTotal(:,3)))/(m1+m2+m3));
CMJunta67 = ((m1*CMTotal(:,5))+m2*(CMTotal(:,4))/(m1+m2));
CMJunta8 = ((m1*CMTotal(:,5))/(m1));

% Calculo dos momentos, em N.m:
% Momentos da Perna Esquerda:
t1L = ((2*m1+2*m2+m3) * g * (CMJunta12(2,1) * 0.001)); 
t2L = ((2*m1+2*m2+m3) * g * (CMJunta12(1,1) * 0.001));
t3L = ((m1+2*m2+m3) * g * (CMJunta3(1,1) * 0.001));
t4L = ((m1+m2+m3) * g * (CMJunta45(1,1) * 0.001));
t5L = ((m1+m2+m3) * g * (CMJunta45(2,1) * 0.001));

% Momentos da Perna Direita:
t5R = ((m1+m2) * g * (CMJunta67(2,1) * 0.001));
t4R = ((m1+m2) * g * (CMJunta67(1,1) * 0.001));
t3R = ((m1) * g * (CMJunta8(1,1) * 0.001));

% Concatenaçao dos momentos:
t_L = [t1L; t2L; t3L; t4L; t5L];
t_R = [t5R; t4R; t3R];

M1L = horzcat(M1L,t_L(1,1));
M2L = horzcat(M2L,t_L(2,1));
M3L = horzcat(M3L,t_L(3,1));
M4L = horzcat(M4L,t_L(4,1));
M5L = horzcat(M5L,t_L(5,1));

M5R = horzcat(M5R,t_R(1,1));
M4R = horzcat(M4R,t_R(2,1));
M3R = horzcat(M3R,t_R(3,1));