[Math] Finding & Plotting equation of hyperbola given foci, and difference in distances between them.

algebra-precalculusanalytic geometryconic sections

I have to plot the hyperbola (3 of them actually) in MATLAB, and so it'd be good if I could find some sort of general formula.

The foci do not necessarily have to be on the axes (e.g. $(5,3)$ and $(4,8)$ can also be the foci).
I have the difference in distances between them at a point which lies on the hyperbola. Will there be a general equation describing this hyperbola? If yes, what will it be? (e.g. say the points are $(x_1,y_1)$ & $(x_2,y_2)$ and difference in distance is $d$).

I know that I can shift and rotate the axes so that I get what I want, but I wanted to know if there was a better method, since while plotting i'll have to reconvert the values into the normal axes.

I'm going to try trilateration, which is why i'm asking for the equation.

Best Answer

say the points are $(x_1,y_1)$ & $(x_2,y_2)$ and difference in distance is $d$

Could you use the literal translation of this statement into algebra? $$\left|\sqrt{(x-x_1)^2+(y-y_1)^2}-\sqrt{(x-x_2)^2+(y-y_2)^2}\right|=d$$ or $$\left(\sqrt{(x-x_1)^2+(y-y_1)^2}-\sqrt{(x-x_2)^2+(y-y_2)^2}\right)^2=d^2$$ or $$(x-x_1)^2+(y-y_1)^2+2\sqrt{(x-x_1)^2+(y-y_1)^2}\sqrt{(x-x_2)^2+(y-y_2)^2}+(x-x_2)^2+(y-y_2)^2=d^2$$