I wrote a C++
program that can calculate the magnetic field $\bar{B}$ generated by a circular coil that is placed in the origin, for a given point $\bar{P}$ in 3D space.
The coil is in the $x$,$y$-surface, with $z=0$.
I want to describe multipoles now so I would have to be able to transform the coordinates of $\bar{P}$ to the coordinate system of a coil that is shifted and rotated $\bar{P}^\prime$.
The coils that are shifted and rotated would have their coordinate systems like so:
the origin of the coil system is at $O^\prime=(R\cos\phi,R\sin\phi,0)$
The $z^\prime$-axis points to the origin of the normal system, is also in the $x$,$y$-surface and makes an angle $\phi$ with the $x$-axis of the normal system.
The $y^\prime$-axis is parallel to the $z$-axis
the $x^\prime$-axis follows (all systems being orthonormal).
Thus all coils (the number of coils is arbitrary) lie on a circle with radius $R$ and their central axis $z$.
My approach has been this so far:
- transform $\bar{P}$ to $\bar{P}^\prime$ in the coil's system
- calculate $\bar{B}^\prime$ using my program
- transform $\bar{B}^\prime$ back to the normal system (only rotation has to be undone, since $\bar{B}$ is a free vector and I only need it's components).
I've been using a transformation matrix $M=R_y(\phi)R_x(\pi/2)$ that looks like this: $M=\begin{bmatrix}\cos\phi&0&\sin\phi\\0&1&0\\-\sin\phi&0&\cos\phi\end{bmatrix}\begin{bmatrix}1&0&0\\0&0&-1\\0&1&0\end{bmatrix}=\begin{bmatrix} \cos\phi&\sin\phi&0\\0&0&-1\\-\sin\phi&\cos\phi&0\end{bmatrix}$
so $\bar{P}^\prime=M\bar{P}$, after first translating $\bar{P}$ to $\bar{P}_t$ by: $\bar{P}_t=\bar{P}-O^\prime$
And $\bar{B}=M^\prime \bar{B}^\prime$ with $M^\prime=M^T$.
My results are fautly, so what am I doing wrong?
Also, let me know if this question is too concrete to post on a math forum.
Added image for clarity: The gray circle is where the coil always is in the system that's being used for my C++
program, the dark circle is the coil where it should be.