How to use POV-Ray to draw a cylinder
The Persistence of Vision Raytracer, commonly known as POV-Ray, is a 3D graphics tool.
The cylinder is one of the most commonly used shapes. In this Answer, we'll learn how to draw a cylinder object using POV-Ray.
Implementation
The demo code used to draw a cylinder is as follows:
#version 3.7;
#include "colors.inc"
background { color White }
camera {
location <0,-6,-6>
look_at <1,1,1>
}
light_source {
<-50, 50, -50>
color White
}
cylinder {
<0, 3, 0>, // Center of one end
<3, 4, 5>, // Center of other end
1.5 // Radius
open // Remove end caps
texture {
pigment {
image_map {
png "cylinder-map.png"
map_type 1
}
}
finish { ambient 0.3 diffuse 0.5 specular 0.2 }
}
}
Explanation
Lines 1–4: We include the required libraries and set up the background color to white.
Lines 6–9: A
camerastatement is added to visualize the scene defining thelocationandLook-atwithx,y, andzcoordinate values.Lines 11–14: The
light_sourcestatement is introduced to add light to the scene.Lines 17–31: The
cylinderstatement is implemented with the center of the one end as the first parameter, the center of the other end as a second parameter, radius as the third parameter, andopento draw open edges as the fourth argument.
Free Resources