Revision 70768178-9cde-42fb-ab5f-dba9c91388f9 - Code Golf Stack Exchange
# JavaScript (ES6), 136 bytes
Expects `(p)(q)` and returns \$p\lozenge q\$.
<!-- language-all: lang-javascript -->
p=>q=>((g=(t,h=o=[1],v=n=x=y=0)=>n-t|x-t[0]|y-t[1]?g(t,...o[o[[x-=h,y-=v]]=++n,[x-v,y+h]]?[h,v]:[v,-h]):x)(q),Y=2*y,g([2*x-g(p),Y-y]),n)
[Try it online!](https://tio.run/##dZDdjoIwEIXv9ym47GiLbfkrJqPPsWl6YVwFN4bqSggkvjtbARO3uDdtMt@cM2fme9fsbvuf06Vmlf069EfsL7i54oaQAklNS7SohaENVthihxxwU7H63rJac3Pv3CfMtnCdYRhabbVuGZa0Y9gYg8tlRV2hod2yNGarS9qYtW4oKw2sWyBXoJ8oFx0tiJaLlhXk4iqsM0Ar6Pe2utnzITzbghxJEAhwTw4QrFaBTD7eYjliIXws/uC3VPB/vXMYBgx4RsVA48k68nGWPnA64lTO1BkMz6jOfJxKh5NkSparWbQIhvgjn8mFGx7zaTEh89RrEMr5y3hqiLjPZfy6ulT@5Vzllce5HyB65M/VFGA2P1AKhpSjns/Ok3LH46e/4D5PHvnU8z4y638B "JavaScript (Node.js) – Try It Online")
### How?
The helper function \$g\$ expects a target \$t\$ which is either the index _or_ the coordinates of an element in the spiral. Whenever \$g\$ is called, it starts at the origin and walks through the spiral until the target is reached, keeping track of its index \$n\$ and its position \$(x,y)\$ (all these variables being available in the global scope).
We first invoke \$g(q)\$ to get the coordinates \$(X,Y)\$ of the 2nd element, then \$g(p)\$ to get the coordinates \$(x,y)\$ of the 1st element, and finally \$g([2X-x,2Y-y])\$ to get the index of \$p\lozenge q\$.