%%
clc

% /*
%    This function calculates the activity values of the  Eye-position format which are presented in a forward
%    direction to the hidden layer
% */
% 
%        /*
% 	  function that generates motoneuron activation profile:
% 	      F = alfa * (Eye position - Threshold)
% 	  Furthermore: alfa depends on threshold according to:
% 	   alfa = 0.1 * Threshold + 9.0 (instead of 7.6)
% 	     (see Van Gisbergen and Van Opstal, Chapter III: Models, Fig. 1)
%        */

%void eyepos_input(eyepos, hor)
% eyepos;
% hor;
% 
% 
% double; 
% thresh; 
% slope; 
% rate ;
% x;
% j;

hor=6;
Nmsc=100;
eyepos=zeros(2,Nmsc);

% GAIN_EYEPOS: 1;
% GAIN_MOTOR: .7;
Gain_mot=1/400;
Gain_pos=0.7;


	     

	for j=1:1:Nmsc
		
		thresh = -50 + (80 * ( j - 1) / (Nmsc - 1) );
		
		
		%/* NEGATIVE SLOPE Horizontal MOTONEURONS */
		slope  = -Gain_mot * (90 - thresh) / 10  ;
		
			if  (hor  <= thresh) rate = slope * (hor - thresh) 
				else rate = 0;
			end
			
			eyepos(1,j) = rate * Gain_pos;
			
			
		%/* POSITIVE SLOPE Horizontal MOTONEURONS */
		slope  = +Gain_mot * (90 + thresh) / 10;
		
			if  (hor - thresh >= 0) rate = slope * (hor - thresh) ;
				else rate = 0;
			end;
			
			eyepos(2,j)= rate * Gain_pos;
			
	end


	 
	
	
     figure(2)
     hold off
     plot((eyepos(1,:)),'k');
	 hold on
	 plot((eyepos(2,:)),'r');
	


	%/* *************** END  EYE_POS OUTPUT *************** */
