How do I find the perpendicular velocity of a particle to a varying magnetic field? I am trying to find the component of velocity perpendicular to a magnetic field. This was easy when the magnetic field was static and pointing in only one direction (the $z$ axis), but now I need to find it for any arbitrary velocity and magnetic field vector (in Cartesian coordinates). I have tried subtracting the dot product of the two vectors from the magnitude of the velocity vector, but that doesn't seem to be working. 
 A: This is just a vector projection problem. The fact that one of the vectors happens to represent a magnetic field is irrelevant.
The component of velocity perpendicular to the magnetic field is the total velocity minus the component parallel to the magnetic field. I.e., it's the velocity minus it's projection in the direction of the magnetic field (also called the rejection of velocity onto the magnetic field).
If $v$ is our velocity vector and $B$ is out magnetic field vector, then the rejection $v_r$ of $v$ onto $B$ is given by 
$ v_r = v - \frac{v \cdot B}{B \cdot B}B $
Which is equivalent to
$ v_r = v - (v \cdot \hat{B})\hat{B} $
where $\hat{B}$ is the unit vector indicating the direction of the magnetic field.
A: Although Logan wrote a correct solution, I find it is almost always helpful to draw yourself a diagram:

Vector $\vec v$ is the velocity, and $\vec B$ is the magnetic field. You want to get $\vec p$, which requires you to add $\vec m$ to $\vec v$.
Thus the problem is reduced to finding $\vec m$, which is the projection of $\vec v$ onto $\vec B$. This can be done as
$$\vec m = -\frac{(\vec v \cdot \vec B)\ \vec B}{\lvert{\vec B}\rvert^2}$$
where $\lvert \vec B \rvert$ is the magnitude of $\vec B$.
Finally, $$\vec p = \vec v + \vec m$$
