So I want to rotate the helix $$ \begin{cases} x=\cos(t),\\ y=t,\\ z=\sin(t), \end{cases} $$ so that it wraps ground a vector $(X,Y,Z)^T$. I first get the theta by $$ \theta=\arctan\left(\frac{Z}{Y}\right) $$ Then I use the rotation equation around the $x$-axis. $$ R_x= \begin{bmatrix} 1 & 0 & 0\\ 0 & \cos(\theta) & \sin(\theta)\\ 0 &-\sin(\theta)& \cos(\theta) \end{bmatrix} $$ and multiply $$ R_1=R_x\cdot(\cos(t), t, \sin(t))^T $$ So the rotation here looks fine. Then I do another rotation around the $z$-axis. $$ \phi=2\pi-\arctan\left(\frac{Z}{Y}\right)$$ $$R_z= \begin{bmatrix} 1&0&0\\ 0 &\cos(\phi) &-\sin(\phi)\\ 0 &\sin(\phi) &\cos(\phi) \end{bmatrix}\\$$ $$R_z\cdot R_1$$ The final rotation is in the correct axis, however it does't wrap around the vector; it is slightly off when graphing this in a 3D coordinates system. I wanted to know if I'm using the equations correctly or am I taking the angle of rotation wrong. Thanks!
Also I'm using the vector $(X, Y, Z)^T=(12,13,15)^T$.
Example: first rotation $$ \theta=\arctan\left(\frac{15}{13}\right)=0.85671 $$
$$ R_x= \begin{bmatrix} 1 & 0 & 0\\ 0 & 0.65493 & -0.75569\\ 0 & 0.75569 & 0.65493\\ \end{bmatrix} $$
$$ R_x*helix= \begin{bmatrix} cos(t)\\ 0.6549⋅t - 0.7557⋅sin( t)\\ 0.7557⋅t + 0.6549⋅sin( t) \end{bmatrix} $$
second rotation
$$ \phi=\arctan\left(\frac{12}{13}\right)=0.74542$$
$$ R_z= \begin{bmatrix} 0.73480 0.67828 0\\ -0.67828 0.73480 0\\ 0 0 1\\ \end{bmatrix} $$
$$ R_z*(R_x*helix)= \begin{bmatrix} 0.4442⋅t - 0.5126⋅sin(t) + 0.7348⋅cos(t)\\ 0.4812⋅t - 0.5553⋅sin(t) - 0.6783⋅cos(t)\\ 0.7557⋅t + 0.6549⋅sin(t) \end{bmatrix} $$
Graph: As you can see in the image the helix does not wrap around the vector after doing both the rotations. enter image description here
The idea for wrapping a given helix around a given vector is to map the axis of the given helix onto the given vector. Once done this, a degree of freedom remains to establish the rotation of the helix around its axis.
To map the helix axis (let it be $v_0 = (0,1,0)^T$) to the given vector (let it be $v_1 = (X,Y,Z)^T$) a possibility is to use the following two rotations: the first, $R_x$, around the $x$-axis that maps $v_0$ to the right polar angle and the second, $R_z$, around the $z$-axis that adjusts the azimuthal angle (see, e.g., the Wikipedia Spherical coordinate system for an introduction to polar and azimuthal angles).
The rotation $R_x$ describes a counter-clockwise rotation around $x$-axis (viewed from point $(1,0,0)^T$): $$ R_x= \begin{bmatrix} 1&0&0\\ 0&\cos(\phi)&-\sin(\phi)\\ 0&\sin(\phi)&\cos(\phi) \end{bmatrix}, $$ where the angle $\phi$ is the polar angle given by $$ \phi= \arcsin\left(\frac{Z}{\sqrt{X^2+Y^2+Z^2}}\right). $$ The rotation $R_z$ describes a counter-clockwise rotation around $z$-axis (viewed from point $(0,0,1)^T$): $$ R_z= \begin{bmatrix} \cos(\theta)&\sin(\theta)&0\\ -\sin(\theta)&\cos(\theta)&0\\ 0&0&1 \end{bmatrix}, $$ where the angle $\theta$ is the azimuthal angle given by $$ \theta= \arcsin\left(\frac{X}{\sqrt{X^2+Y^2}}\right). $$
We should have, at this point, that $R_z(R_x(v_0)) = v_1$, i.e., the axis of the original helix should have been mapped onto $v_1$, and as a consequence, the new helix should wrap around the given axis.