I am trying to draw a cylinder in OpenGl. I found this algorithm but I can’t make any sense of it.
http://paulbourke.net/miscellaneous/sphere_cylinder/
“Given the two perpendicular vectors A and B one can create vertices around each rim of the cylinder. So, for a 4 vertex facet the vertices might be given by the following where theta2 – theta1 is some suitably small angle that determines the roughness of the approximation.”
How can I find A and B ?? I am using glm. can glm calculate cross product?
A and B form the base of a orthogonal (prefarably orthonormal), cartesian 2D coordinate system. Think of them like X and Y axes. Recall that the parametric equation for a circle is
Now replace X and Y with A, B, and you got the equation for the circular cross section of a cylinder. To make it a cylinder you extrude by the vector perpendicular to A and B, i.e. C = A × B