The distance between objects is easy:
_dis=obj1 distance obj2
The direction requires a bit of calculation. There is probably an easier way but this is how I do it, using a function.
Make a file called "direction.sqf"
private ["_ux","_uy","_dx","_dy","_diffx","_diffy"];
_ux = (_this select 0) select 0;
_uy = (_this select 0) select 1;
_dx = (_this select 1) select 0;
_dy = (_this select 1) select 1;
_diffx = (_dx-_ux);
if (_diffx==0) then {_diffx=.001};
_diffY = (_dy-_uy);
_dir = atan( _diffy/_diffx );
if (_diffx>0) then {_dir=90-_dir};
if (_diffx<0) then {_dir=270-_dir};
_dir
In your init.sqs file, put this line:
direction = preprocessfile "direction.sqf"
This actually finds the direction from one position to another position, not actually objects. To use, do this:
_dir=[getpos object1,getpos object2] call direction
_dir will be the direction of object1 to object2.
Like I said, there is probably a shorter way but this works.