Just as a side note I forgot to add, I was clumsying around getting it to work but it was acting weird all the time, while in my head the calculations were right. Turned out temp2_pos.z wasn't at 0 (because VECTOR temp2_pos; doesn't initialise its members (x, y, z) to 0, but leaves it with some random pointer address), so vec_dist returned a very awkward value.
Setting temp2_pos.z to 0 helped alot

.