// init - initCommAPI parameter controls whether I2C/SPI interface is initialised (set to false if other devices are on the I2C/SPI bus and have already initialised the interface)
conv_factor=(1.0/(float)(num_pixels*scaler))*2.0*tan(field_of_view/2.0);// multiply this number by altitude and pixel change to get horizontal move (in same units as altitude)
// convert raw change to horizontal movement in cm
x_cm=-change_x*avg_altitude*conv_factor;// perhaps this altitude should actually be the distance to the ground? i.e. if we are very rolled over it should be longer?
y_cm=-change_y*avg_altitude*conv_factor;// for example if you are leaned over at 45 deg the ground will appear farther away and motion from opt flow sensor will be less
// calculate expected x,y diff due to roll and pitch change
floatexp_change_x=omega.x*radians_to_pixels;
floatexp_change_y=-omega.y*radians_to_pixels;
// real estimated raw change from mouse
floatchange_x=dx-exp_change_x;
floatchange_y=dy-exp_change_y;
// convert raw change to horizontal movement in cm
floatx_cm=-change_x*altitude*conv_factor;// perhaps this altitude should actually be the distance to the ground? i.e. if we are very rolled over it should be longer?
floaty_cm=-change_y*altitude*conv_factor;// for example if you are leaned over at 45 deg the ground will appear farther away and motion from opt flow sensor will be less