function [h,d_floor,rho] = init_sensor(t,y,f,a,b,dmin_fovea,log_polar)
%
%Instituto Superior Técnico - Instituto de Sistemas e Robótica - 			             09/2001
%OMNIVIEWS PROJECT    -   SVAVISCA sensor									[ccgd,jasv@isr.ist.utl.pt]
%
%function [h,d_floor,rho] = init_sensor(t,y,f,a,b,dmin_fovea,log_polar)
%
% This program choose the sensor that maps the floor in the fovea mirror and 
% the vertical dimension in the retina mirror. The function in vertical dimension 
% is equal h = a*log(log(rho)-log(rhoc))/log(k) + b  for log-polar camera and 
% h= a*rho +b for conventional camera. for the fovea this funcion is equal 
% d_floor = a*rho+dmin_fovea (equivalent to h = a*rho + b)
%
% t [cm] - distance vector in the horizontal coordinate for the mirror
% Yo [cm]: minimum distance from the mirror to the camera, Fo = (t*f)/rho;
% log_polar = 1/0 : log polar / cartesian camera
% f [cm]- lens focal length in cm (2.5 for log-polar; 1.25 for cartesian)
% d [cm]- radius of the cilinder where the vertical resolution should be kept uniform (200cm)
% a - gain of the mirror
% b [cm] - offset  (set by minimum angle for the retina mirror: vertical dimension)
% dmin_fovea - offset (set by minimum angle of the fovea: floor)
% ipheight [cm]- image plane height: height between the floor and image plane

%Output parameters:
% rhoc - radial distance in the sensor (ccd)
% d_floor - distance in the horizontal distance (floor) that is maped in the fovea region
% h - value of function h(rho)

%log-polar sensor parameters
k = 1.02337; 		%grow rate of the pixel size for the log polar sensor
rhoc = 0.027273 ; %first value of rho for the log polar sensor [cm]


rho= (f*t)./(y-f);

if log_polar==1
   logk = (log(rho)-log(rhoc))/log(k);
   h = a*logk + b;
   d_floor = a*logk + dmin_fovea;
else
   h= a*rho +b;
	d_floor = a*rho+dmin_fovea;	%d(rho) = a*rho+b; where b = set by minimum angle of the fovea
end

