link to diagram for explanation: https://i.stack.imgur.com/YnUMY.png

I am trying to determine the distance between i and j.
These nodes are all placed in a coordinate system.
things I know:
- coordinates of i, p and q.
- distance ip.
- distance iq.
- distance pq.
- distance pj.
- distance qj.
Does anybody know a way of doing this? Thanks