d= d2+d1
you have to assign both of the directions a either positive or negative.
for example
if you have north and south
you would assign north to positive
and south would be negative
if you have east and west
you would assign east to positive
and west to negative