I am language challenged, and your code will not compile in isolation, but ...
by example ... it seems to me that if you know the absolute base point < 0, 0, 0>
and you know the object reference point, say < 10, 20, 5 >
and the co-ordinate is say < 11, 33, 4 >
then the relative distance is
11 - 10 = 1
33 - 20 = 13
4 - 5 = -1
.. but I may be mis-understanding your dilema.
If you need to include translations between UCS's the algorithm becomes a little more complicated, but is essentially the same.