A formula says more than thousend words

. The formula in question here is Ampere's Law, i.e., one of the Maxwell equations, specialized for stationary currents. It says

[tex]\vec{\nabla} \times \vec{B}=\vec{J}.[/tex]

Further you need the fact that there are no magnetic charges ("monopoles"):

[tex]\vec{\nabla} \cdot \vec{B}=0.[/tex]

This together Ampere's Law tells you that only some current density can cause a magnetic field (in this special case of stationary, i.e., time-independent situations). This tells you that it is only this current density determines the direction and magnitude of the magnetic field. The current density of a single particle is given by

[tex]\vec{J}=q \int \mathrm{d} t \dot{\vec{y}}(t) \delta^{(3)}[\vec{x}-\vec{y}(t)],[/tex]

where [itex]\vec{y}(t)[/itex] is the trajectory of the particle. This tells you that the sign of the charge, of course included in the current density, determines wether the current at any instance of time is pointed in (positive charge) or against (negative charge) the particle's velocity. What goes into the magnetic field is still only the current density and that's it.

The right-hand rule to determine the direction of the [itex]\vec{B}[/itex] thus applies to this current density and nothing else: Point the thumb of your right hand in direction of the current density the fingers tell you the direction of the magnetic field. That's what's written in Ampere's Law, becaus it is customary to define the vector operations in three-dimensional Euclidean space always according to right-hand rules.

To see this quantitatively at work, we have to solve for the magnetic field in terms of the current density. The vanishing of magnetic charge implies that there exists a vector potential for the magnetic field, i.e.,

[tex]\vec{B}=\vec{\nabla} \times \vec{A}.[/tex]

Further we can use Cartesian coordinates to calculate the curl:

[tex]\vec{\nabla} \times \vec{B}=\vec{\nabla} \times (\vec{\nabla} \times \vec{A})=\vec{\nabla}(\vec{\nabla} \cdot \vec{A})-\Delta \vec{A}.[/tex]

Now the vector potential is only determined up to the gradient of a scalar field, and thus we can impose one scalar constraint on it. In modern slang the physicists call this "fixing a gauge". Here, it's most convenient to use "Coulomb Gauge", i.e.,

[tex]\vec{\nabla} \cdot \vec{A}=0.[/tex]

With this Ampere's Law simplifies to

[tex]\Delta \vec{A}=-\vec{J}.[/tex]

This is just the same law (for each component) as that for the electric potential in electrostatics, and thus we can write down the solution immediately. Behind this is of course the Green's function of the Laplace operator:

[tex]\vec{A}(\vec{x})=\frac{1}{4 \pi} \int \mathrm{d}^3 \vec{x}' \frac{\vec{J}(\vec{x}')}{|\vec{x}-\vec{x}'|}.[/tex]

It is easy to check that this solution indeed fufills the Coulomb-gauge condition, because from Ampere's Law we must impose the constraint

[tex]\vec{\nabla} \cdot \vec{J}=0,[/tex]

which is nothing else than the conservation of electric charge for the here considered special case of stationary currents.

Now we evaluate the magnetic field. For this we need to take the curl of the above solution. We can lump the differentiation operator under the integral and then use

[tex]\vec{\nabla} \times \frac{\vec{J}(\vec{x}')}{|\vec{x}-\vec{x}'|} = -\vec{J}(\vec{x}') \times \vec{\nabla} \frac{1}{|\vec{x}-\vec{x}'|}=+\vec{J}(\vec{x}') \times \frac{\vec{x}-\vec{x}'}{|\vec{x}-\vec{x}'|^3}.[/tex]

This gives you finally Biot-Savart's Law

[tex]\vec{B}(\vec{x})=\frac{1}{4 \pi} \int \mathrm{d}^3 \vec{x}' \vec{J}(\vec{x}') \times \frac{\vec{x}-\vec{x}'}{|\vec{x}-\vec{x}'|^3}.[/tex]

This formula only deals with vector manipulations and is thus valid in any coordinate system (not only Cartesian coordinates).

More intuitive as an example than the magnetic field of a point charge is a steady current along an infinite very thin straight wire. Let's choose the [itex]z[/itex] axis to be directed in the direction of the current densitiy. For this situation we have (in Cartesian coordinates)

[tex]\vec{J}(\vec{x}')=\vec{e}_z I \delta(x') \delta(y').[/tex]

Then we have

[tex]\vec{B}(\vec{x})=\frac{1}{4 \pi} \int \mathrm{d} z' I \vec{e}_z \times \frac{x \vec{e}_x+y \vec{e}_y}{\sqrt{(z-z')^2+x^2+y^2}^{3}}.[/tex]

The evaluation of the integral gives

[tex]\vec{B}(\vec{x})=\frac{I}{2 \pi} \vec{e}_z \times \frac{\vec{x}}{x^2+y^2}.[/tex]

It's more intuitive to write this in terms of cylinder coordinates

[tex]\vec{B}(\vec{x})=\frac{I}{2 \pi \rho} \vec{e}_{\varphi}.[/tex]

As you see, the right-hand rule works: The magnetic field curls around the current-conducting wire counter-clockwise when looking against the current density.

Note that we do not have to think about the motion of the electrons in the wire at all. Of course, they move in negative [itex]z[/itex] direction. Together with their negative charge the current density points into positive [itex]z[/itex] direction.