I am given geometry of a cylinder which lies on the XY plane with 1 unit radius. And given coordinates of 2 points in 3D I need to move the cylinder so that it connects the two points.What I tried so far after searching online:Calculated the vector between the two points p = p1 - p2;Took the normal vector to the plane(0,0,1) vAxis of rotation = v x p (cross)angle of rotation = acos(|v|.|p|) (unit vectors)I applied this rotation.Translated one of the end point of cylinder to one of the points.but it moves the object to a wrong location. Any help what I'm doing wrong?EDIT: My apologies for not being able to respond.The main issue was with this line.angle of rotation = acos(|v|.|p|) (unit vectors)I normalized the vectors then used this wrong formula. Which will always return 90 degrees.I am still not getting exactly the correct output. Here is the screenshot.
Rotate a cylinder from XY plane to given points
opengl;transformations