function Animation3D_DS( Pref_r,Pref_l,Q_r,Q_l,L,M,wleg ) % COG, COP )

 global save_P_r save_C_r save_F_r save_H_rl save_P_l save_C_l save_F_l SAVE_ans ZZ
 global save_COG_r save_COG_rl save_COG_l save_COG
 %/////////////////////////////////////////////////////////////////////////
 % SIMULATING THE REAL SYSTEM
 %/////////////////////////////////////////////////////////////////////////
 if wleg == +1,
    [P_r,P_hip] = DirKin6dof_stance( Pref_r,Q_r,L,wleg );
    [C_r,F_r,H_rl,T_hip] = JointCoord_stance( Pref_r,Q_r,L,wleg );
    P_l = DirKin6dof_stance( Pref_l,Q_l,L,-wleg );       
    [C_l,F_l] = JointCoord_stance( Pref_l,Q_l,L,-wleg );
    
    [COG_r,COG_rl] = RobCOG_stance( Pref_r,Q_r,L,M,wleg );
    [COG_l] = RobCOG_stance( Pref_l,Q_l,L,M,-wleg );
    COG = RobCOG(COG_r,COG_rl,COG_l,M);
    %COG_r = RobCOG( qi,L,R,M );
    % Q_r, P_r %-----------------------------------------------------------
 else 
     [P_l,P_hip] = DirKin6dof_stance( Pref_l,Q_l,L,wleg );
     [C_l,F_l,H_rl,T_hip] = JointCoord_stance( Pref_l,Q_l,L,wleg );
     P_r = DirKin6dof_stance( Pref_r,Q_r,L,-wleg ); 
     [C_r,F_r] = JointCoord_stance( Pref_r,Q_r,L,-wleg );
     
     [COG_l,COG_rl] = RobCOG_stance( Pref_l,Q_l,L,M,wleg );
     [COG_r] = RobCOG_stance( Pref_r,Q_r,L,M,-wleg );
     COG = RobCOG(COG_r,COG_rl,COG_l,M);
     %COG_r = RobCOG( qi,L,R,M );
     % Q_r, P_r %-----------------------------------------------------------     
 end
 CreateWorldBodies( P_r,C_r,F_r,COG_r,H_rl,COG_rl,P_l,C_l,F_l,COG_l,COG )
%-------------------------------------------------------------------------- 
  if SAVE_ans == 1,       
     % P_r, disp('STEP1:DS'), pause 
     save_P_r(:,ZZ) = P_r; save_C_r(:,:,:,ZZ) = C_r; save_F_r(:,:,:,ZZ) = F_r; save_COG_r(:,:,ZZ) = COG_r;
     save_H_rl(:,:,:,ZZ) = H_rl; save_COG_rl(:,ZZ) = COG_rl;
     save_P_l(:,ZZ) = P_l; save_C_l(:,:,:,ZZ) = C_l; save_F_l(:,:,:,ZZ) = F_l; save_COG_l(:,:,ZZ) = COG_l;
     save_COG(:,ZZ) = COG;
     ZZ = ZZ + 1;     
  else
      if ZZ ~= 1, SAVE_ans = 1; end
  end
end