Basically you just need to allocate A and B positions.
So let
A = (x1,y1)
B = (x2,y2)
P is a variable so (x,y)
Therefore, using the distance formula
(PA)^2 = (x-x1)^2+(y-y1)^2
(PB)^2 = (x-x2)^2+(y-y1)^2
Then the difference between these equals 5
So
[(x-x1)^2+(y-y1)^2]-[(x-x2)^2+(y-y1)^2] = 5
(x-x1)^2+(y-y1)^2-(x-x2)^2-(y-y1)^2 = 5
Using difference of squares
[(x-x1)-(x-x2)][(x-x1)+(x-x2)] + [(y-y1)-(y-y2)][(y-y1)+(y-y2)] = 5
(x2-x1)[2x-(x2+x1)] + (y2-y1)[2y-(y2+y1)] = 5
2x(x2-x1) - [(x2)^2-(x1)^2] + 2y(y2-y1) - [(y2)^2-(y1)^2] = 5
Now, make y the subject.
2y(y2-y1) = - 2x(x2-x1) + [(x2)^2-(x1)^2] + [(y2)^2-(y1)^2]+5
y = {- 2x(x2-x1) + [(x2)^2-(x1)^2] + [(y2)^2-(y1)^2]+5 } / [y2-y1]
If we examine this equation very carefully, it's actually a straight line in the form y=mx+b since x1,x2,y1,y2 are all constants.
It looks really complicated but yeah o_o
Hrmm,,
It'd simplify quite nicely if there were values for A and B I'm pretty sure...