Original Post
I have to spheres in my opengl window (S and T), and I want to draw a cylinder (C) between them. The sphere is connected to S via a translation, however I am not sure how to to calculate the required rotations to make the other end of C connect to T. My code currently looks like this: dx = Tx - Sx; dy = Ty - Sy; dz = Tz - Sz; len = sqrt((dx * dx) + (dy * dy) + (dz * dz)); angle = atan2(dz, dx); angle = (180 * angle) / PI; glRotatef(angle, 0.0f, 1.0f, 0.0f); angle = atan2(dy, dz); angle = (180 * angle) / PI; glRotatef(angle, 1.0f, 0.0f, 0.0f); angle = atan2(dy, dx); angle = (180 * angle) / PI; glRotatef(angle, 0.0f, 0.0f, 1.0f);