A lathe is a tool for operating on an object while it rotates around an axis of rotation. An example is the potter’s wheel for sculpting clay into symmetrical cups and bowls. As the potter sculpts the bowl’s surface, rotation ensures the bowl’s rotational symmetry. The LatheGeometry
class is used to create geometries by rotating a plane curve around an axis of rotation in similar fashion. In the following program, the curve is a circular arc belonging to an origin-centered circle in the xy-plane. When the arc is rotated around the vertical y-axis, a spherical band results.
The first two parameters in our createSphericalBandGeometry
function determine the radius of the sphere containing the band and half the angle (in radians) that the band subtends. The segments
parameter is the number of segments around the band’s circumference. The density
parameter is the number of points used to define the circular arc.
function createSphericalBandGeometry(rad, angle, segments, density) { let h = 2 * angle / (density - 1); let points = []; for (let i = 0; i < density; i++) { let a = -angle + i * h; // current angle let x = rad * Math.cos(a); let y = rad * Math.sin(a); let p = new THREE.Vector2(x, y); points.push(p); } return new THREE.LatheGeometry(points, segments); }
The LatheGeometry
constructor is more general than appears in this program:
LatheGeometry(points, segments, phiStart, phiLength)
We’ve talked about the first two parameters. phiStart
is the starting angle of the first segment relative to the x-axis, which defaults to 0. And phiLength
is the range of the lathed section (the amount that the curve is rotated), a value between 0 and 2π. phiLength
‘s default value of 2π yields a closed section, whereas smaller values produce open sections due to only partial rotation.