I assume you know how to find vector which connect between center of two particles.
if one is (x1,y1,z1),another one is (x2,y2,z1). then the vector $\vec{r}$ is (x2-x1,y2-y1,z2-z1).
Assume velocity of particle 1 is$vec{v}$= (vx1,vy1,vz1),
The velocity component in the vector $vec{r}$ direction can be calculated as $\vec{v_p}=(\vec{v}\cdot\vec{r})/r^2 \vec{r}$,where $r$ is the length of velocity $\vec{r}=\sqrt{(x2-x1)^2+(y2-y1)^2+(z2-z1)^2}$

i.e.
vx1'=((vx1*(x2-x1)+vy1*(y2-y1)+vz1*(z2-z1))/r^2) (x2-x1)
vy1'=((vx1*(x2-x1)+vy1*(y2-y1)+vz1*(z2-z1))/r^2) (y2-y1)
vz1'=((vx1*(x2-x1)+vy1*(y2-y1)+vz1*(z2-z1))/r^2) (z2-z1)

And the velocity compendicular to $vec{r}$ is $\vec{v_n}=\vec{v}-\vec{v_p}$

P.S. The inner product between $\vec{A}$ and unit vector $\hat{n}$ will give you magnitude of projection of vector $\vec{A}$ in the direction of $\hat{n}=\vec{r}/r$, so the component in the direction $\hat{n}$ is $(\vec{A}\cdot\hat{n}) \hat{n}$