# A Rectangular Toroidal Current-Based Approach for Lung Biopsy Needle Tracking
## 2 Materials and Methods
### Rectangular Toroidal Needle Tracking System
 \tag{4}\]  
\[\overset{\rightarrow}{B_{P}}=\frac{\mu_{0}I}{4\pi}\cdot\sum_{i=1}^{4}\frac{ \overrightarrow{c}_{i}\times\overrightarrow{a}_{i}}{\left|\overrightarrow{ c}_{i}\times\overrightarrow{a}_{i}\right|^{2}}\cdot\left(\frac{\overrightarrow{a}_{i} \cdot\overrightarrow{c}_{i}}{\left|\overrightarrow{c}_{i}\right|}-\frac{ \overrightarrow{a}_{i}\cdot\overrightarrow{b}}{\left|\overrightarrow{b} \right|}\right) \tag{5}\]  
where \(B_{P}\) is the magnitude of the magnetic induction generated by the current carrying a long straight wire at point \(P\), whose direction is compounded by the right-hand rule; \(dz\) is the length of long straight wire in microns, whose distance to the origin of coordinates is \(z\); the angle between \(d\overrightarrow{z}\) and \(\overrightarrow{r}\) is \(\theta\); and \(\theta_{1}\) and \(\theta_{2}\) are the angles between point \(P\) and points \(C,D\). Let the coordinates of the space point \(P\) be \((x,y,z)\), the length of the \(AB\) side be \(2l_{1}\), and the length of the \(BC\) side be \(2l_{2}\); then, the coordinates of the four vertices \(ABCD\) of the rectangular annulus can be represented by \(l_{1}\) and \(l_{2}\), \(A(-l_{1},l_{2},0)\), \(B(l_{1},l_{2},0)\), \(C(l_{1},-l_{2},0)\), \(D(-l_{1},-l_{2},0)\), which are given by Equation (7). \[\left\{ \begin{split}\overset{\rightarrow}{a_{1}}=2l_{1} \overset{\rightarrow}{i}\\ \overset{\rightarrow}{a_{2}}=-2l_{2}\overset{\rightarrow}{j}\\ \overset{\rightarrow}{a_{3}}=-2l_{1}\overset{\rightarrow}{i}\\ \overset{\rightarrow}{b_{1}}=\overset{\rightarrow}{c_{2}}=(l_{1} -x)\overset{\rightarrow}{i}+(l_{2}-y)\overset{\rightarrow}{j}-z\overset{ \rightarrow}{k}\\ \overset{\rightarrow}{b_{2}}=\overset{\rightarrow}{c_{3}}=(l_{1} -x)\overset{\rightarrow}{i}+(-l_{2}-y)\overset{\rightarrow}{j}-z\overset{ \rightarrow}{k}\\ \overset{\rightarrow}{b_{3}}=\overset{\rightarrow}{c_{4}}=(-l_{1} -x)\overset{\rightarrow}{i}+(-l_{2}-y)\overset{\rightarrow}{j}-z\overset{ \rightarrow}{k}\\ \overset{\rightarrow}{b_{4}}=\overset{\rightarrow}{c_{1}}=(-l_{1} -x)\overset{\rightarrow}{i}+(l_{2}-y)\overset{\rightarrow}{j}-z\overset{ \rightarrow}{k}\\ \end{split} \right. \tag{7}\]  
Substituting Equation (9) into Equation (8) yields an expression for the components of the magnetic field in the three directions of the rectangular circulation:  
\[\begin{split} B_{Px}=\frac{\mu_{0}Iz}{4\pi\left[(l_{1}-x)^{2}+z ^{2}\right]}\left(\frac{l_{2}+y}{\sqrt{(l_{1}-x)^{2}+(l_{2}+y)^{2}+z^{2}}}+ \frac{l_{2}-y}{\sqrt{(l_{1}-x)^{2}+(l_{2}-y)^{2}+z^{2}}}\right)\\ -\frac{\mu_{0}Iz}{4\pi\left[(l_{1}+x)^{2}+z^{2}\right]}\left\[ \begin{split} B_{Pt}=\frac{p_{q}q(l_{x}+y)}{4\pi\left[\left(l_{1}-s \right)^{2}+s^{2}\right]}\left(\frac{l_{1}+s}{\sqrt{\left(l_{1}+s\right)^{2}+ \left(s+y\right)^{2}+s^{2}}}+\frac{l_{1}-s}{\sqrt{\left(l_{1}-s\right)^{2}+ \left(l_{2}+s\right)^{2}+s^{2}}}\right)+\frac{p_{q}q(l_{2}-y)}{4\pi\left[ \left(l_{2}-y\right)^{2}+s^{2}\right]}\left(\frac{l_{1}-s}{\sqrt{\left(l_{1} -s\right)^{2}+\left(l_{2}-y\right)^{2}+s^{2}}}+\frac{l_{1}+s}{\sqrt{\left(l_{1} +s\right)^{2}+\left(l_{2}-y\right)^{2}+s^{2}}}\right)+\\ \frac{p_{q}q(l_{1}-s)}{4\pi\left[\left(l_{1}-s\right)^{2}+s^{2} \right]}\left(\frac{l_{1}+s}{\sqrt{\left(l_{1}-s\right)^{2}+\left(l_{2}+s \right)^{2}+s^{2}}}+\frac{l_{2}-s}{\sqrt{\left(l_{1}-s\right)^{2}+\left(l_{2}- y\right)^{2}+s^{2}}}\right)+\frac{p_{q}q(l_{1}+s)}{4\pi\left[\left(l_{1}+s\right)^{2}+ \left(l_{2}+s\right)^{2}+\left(l_{2}+s\right)^{2}\right]}\left(\frac{l_{2}-s}{ \sqrt{\left(l_{1}+s\right)^{2}+\left(l_{2}+s\right)^{2}+s^{2}}}\right)\end{split}  \tag{10}\]  
From Equations (8)-(10), if the positions of the four vertices \(A,B,C,D\) and the point \(t\) in space \(P(x,y,z)\) are known, the magnitude of the magnetic field generated by the rectangular circulation at the point \(B_{Px}\), \(B_{Py}\), \(B_{Px}\) can be determined based on its current.