getAt method

Vector3 getAt(
  1. Vector3 normal,
  2. Vector3 target
)

Implementation

Vector3 getAt(Vector3 normal, Vector3 target) {
  // normal is assumed to be unit length

  final x = normal.x, y = normal.y, z = normal.z;

  final coeff = coefficients;

  // band 0
  target..setFrom(coeff[0])..scale(0.282095);

  // band 1
  target.addScaled(coeff[1], 0.488603 * y);
  target.addScaled(coeff[2], 0.488603 * z);
  target.addScaled(coeff[3], 0.488603 * x);

  // band 2
  target.addScaled(coeff[4], 1.092548 * (x * y));
  target.addScaled(coeff[5], 1.092548 * (y * z));
  target.addScaled(coeff[6], 0.315392 * (3.0 * z * z - 1.0));
  target.addScaled(coeff[7], 1.092548 * (x * z));
  target.addScaled(coeff[8], 0.546274 * (x * x - y * y));

  return target;
}