Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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:

  1. the origin of the coil system is at $O^\prime=(R\cos\phi,R\sin\phi,0)$

  2. 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.

  3. The $y^\prime$-axis is parallel to the $z$-axis

  4. 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:

  1. transform $\bar{P}$ to $\bar{P}^\prime$ in the coil's system
  2. calculate $\bar{B}^\prime$ using my program
  3. 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. the image

share|improve this question
    
Ok I know for sure the matrix $M$ is wrong! Also for inverse transformations one should take the inverse and not the transposed as I have done. Some help on the correct transformation matrix would be great. Also, should I first rotate or first shift? –  romeovs Apr 28 '11 at 17:13
    
The transpose and the inverse of a rotation matrix are the same thing... –  J. M. Apr 28 '11 at 18:47
    
Hm yes your right.. Wow this really isn't my domain. –  romeovs Apr 28 '11 at 18:55
    
$M$ is definitely not a rotation-matrix. How did you arrive at it? –  Gottfried Helms Apr 28 '11 at 19:16
    
I tried two different methods so far: 1. multiply rotation matrices $R_x$, $R_y$ and $R_z$ and 2. put the components of the $a^\prime_i$, calculated in $a_i$ in a matrix. 3. mess around with a graphical program, I think that's were I got this. Was kind of busy so might have messed things up. –  romeovs Apr 28 '11 at 20:22
show 3 more comments

1 Answer

I don't understand how you arrived at your rotation matrix, so I'll just go by your description of the transformed system and the image, which I think I understand.

If we choose $\phi=0$, $O'$ lies on the $x$-axis, so the $z'$-axis should be the negative $x$-axis, the $y'$-axis should be the $z$-axis, and the $x'$-axis should correspondingly be the negative $y$-axis. That corresponds to the transformation matrix

$$\left(\begin{array}{ccc}0&-1&0\\0&0&1\\-1&0&0\end{array}\right)\;.$$

This is not what your expression for the rotation matrix yields for $\phi=0$. Since the $y'$-axis always points along the $z$-axis and only the $x'$-axis and the $z'$-axis are rotated into each other if we change $\phi$, we can immediately infer the general form of the rotation matrix as

$$\left(\begin{array}{ccc}\sin\phi&-\cos\phi&0\\0&0&1\\-\cos\phi&-\sin\phi&0\end{array}\right)\;,$$

where only the sign of the sine was still to be determined and can be fixed by considering $\phi=\pi/2$.

share|improve this answer
    
Okay, I've been trying to fix my program, recalculating and recalculating.. Always coming to this result. Something seems wrong though, my program keeps given faulty results.. –  romeovs May 13 '11 at 17:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.