z1=0.5; %since the height of the cylinder is 1 x1=-1.5; y1=1.5; %getting random trajectory theta=pi/2; Phi= theta; x2= R2*sin(theta)*cos(Phi); y2= R2*sin(theta)*sin(Phi); z2= 0.5;