src/math-helpers.js
function householderTransform (x) {
  // Based on "Matrix Computations" by Golub, Van Loan
  const n = x.dimension;
  const v = x.clone();
  v.x = 1;
  let sigma = 0;
  for (let i = 1; i < n; ++i) {
    const vi = v.getComponent(i);
    sigma += vi * vi;
  }
  let beta = 0;
  if (sigma !== 0) {
    const x1 = x.x;
    const mu = _Math.sqrt(x1 * x1 + sigma);
    const v1 = (x1 <= 0 ? x1 - mu : -sigma / (x1 + mu));
    v.x = v1;
    beta = 2 * v1 * v1 / (sigma + v1 * v1);
    v.multiplyScalar(1.0 / v1);
  }
  return {
    v,
    beta
  };
}
function householderTransform (x) {
  // Based on "Matrix Computations" by Golub, Van Loan
  const n = x.dimension;
  const v = x.clone();
  v.x = 1;
  let sigma = 0;
  for (let i = 1; i < n; ++i) {
    const vi = v.getComponent(i);
    sigma += vi * vi;
  }
  let beta = 0;
  if (sigma !== 0) {
    const x1 = x.x;
    const mu = _Math.sqrt(x1 * x1 + sigma);
    const v1 = (x1 <= 0 ? x1 - mu : -sigma / (x1 + mu));
    v.x = v1;
    beta = 2 * v1 * v1 / (sigma + v1 * v1);
    v.multiplyScalar(1.0 / v1);
  }
  return {
    v,
    beta
  };
}
function householderTransform ( x ) { // Based on "Matrix Computations" by Golub, Van Loan const n = x . dimension ; const v = x . clone ( ) ; v . x = 1 ; let sigma = 0 ; for ( let i = 1 ; i < n ; ++ i ) { const vi = v . getComponent ( i ) ; sigma += vi * vi ; } let beta = 0 ; if ( sigma !== 0 ) { const x1 = x . x ; const mu = _Math . sqrt ( x1 * x1 + sigma ) ; const v1 = ( x1 <= 0 ? x1 - mu : - sigma / ( x1 + mu ) ) ; v . x = v1 ; beta = 2 * v1 * v1 / ( sigma + v1 * v1 ) ; v . multiplyScalar ( 1.0 / v1 ) ; } return { v , beta } ; }
Computes the Householder transform vector and scale.
@memberof Helpers
@param {Vector2|Vector3|Vector4} x The vector to rotate.
Computes the Householder transform vector and scale .