function Q = generalized_force_CL(Dir_contact,Rho_contact,F_contact,u) %{ Function for defining the generalized forces at time t of the integration. -------------------------------------------------------------------------- Syntax : Q = generalized_force(Dir_inT,Rho_inT,F_final,Dir_contact,Rho_contact,F_contact,u) -------------------------------------------------------------------------- Function Description : This function defines the generalized forces acting on the system based on the given values for the contact and muscle forces. If at some point hi on the humerus the contact is lost the relevant contact force will be zero. Yet, we have a zero force in the formula. -------------------------------------------------------------------------- %} F_resultant = zeros(3,1); % initialize the resultant of forces M_resultant = zeros(3,1); % initialize the resultant of moments % we don't consider the muscle forces defined by the feedforward controller % define the resultant force and momemnts at/around HH due to the contact for i = 1:size(F_contact,1) for j = 1:size(F_contact,2) F_resultant = F_contact(i,j)*Dir_contact{i,j} + F_resultant; M_resultant = cross(Rho_contact{i,j},F_contact(i,j)*Dir_contact{i,j}) + M_resultant; end end % calculate the generalized coordinates at time t of the integration e = versatile_function('define partial velocities matrix',u); % define the partial velocities matrix Q = [zeros(3); eye(3)]*F_resultant + [e; zeros(3)]*M_resultant; return;