I think I am not able to convey what I need so here is the edited question:
As you can see in the image, a point on the left is at $(-3,-3,0)$ and the point on the right is at $(3,3,0)$.
And when I draw the cylinder it spawns at $(0,0,0)$, the center point of the cylinder is at $(0,0,0)$ and size of the cylinder is the distance between $2$ points. Now my goal is to rotate the cylinder in all $x$, $y$ and $z$-axis so that it connects both the points.
Here this is a $2$D image so I know that I will need to rotate this only in z-axis but I want a generalized for the points anywhere in the coordinate system.