Rotated parabola

Here we’ll use the LatheGeometry class to rotate a parabola around a line perpendicular to its axis. The parabola is defined by the function x = ay^2 for some constant a. Three points are sufficient to determine the value of a. Given the points (0, 0), (x_1, y_1), and (x_1, -y_1), we have x_1 = ay_1^2, hence a = x_1/y_1^2. We bound the parabola by the points (x_1, y_1) and (x_1, -y_1).

We use the parameter X to indicate the axis of rotation. If X is negative, the rotation axis is x=X (to the left of the curve) and the resulting surface is concave. Alternatively, if X is nonnegative, the rotation axis is x=X+x_1 (to the right of the curve) and the resulting surface is convex. 1

Rotated parabola

Note that the surface changes between convex and concave when the value of X changes sign. The user uses the slider to set the value of x_1 whereas the value of y_1 is set by the program to the constant 8.

The following function generates the surface geometry. Since LatheGeometry rotates around the y-axis (x=0), it’s necessary to translate the curve if X is negative (line 5), or translate and reflect the curve if X is nonnegative (line 7).

function createQuadBandGeometry(x1, y1, X, density=100, segments=12) {
    let a = x1 / (y1 * y1);
    let f;
    if (X < 0) f = (y) => a * y * y - X;
    else
        f = (y) => -(a * y * y - (X + x1));
    let ys = linspace(-y1, y1, density);
    let xs = ys.map(f);
    let vecs = [];
    for (let i = 0; i < ys.length; i++)
        vecs.push(new THREE.Vector2(xs[i], ys[i]));
    return new THREE.LatheGeometry(vecs, segments);
}

The utility function linspace(a, b, n) returns an array of n evenly-spaced values between a and b, where we assume a < b and n > 1.

linspace(a, b, n) {
  let res = [];
  let inc = (b - a) / (n - 1);
  for (let i = 0; i < n; i++)
      res.push(a + i * inc);
  return res;
}
  1. LatheGeometry requires the entire curve to lie on the same side of the axis of rotation and so the rotation axis must lie to its left or its right.