reflect method

V3 reflect(
  1. V3 normal
)

Reflects this vector off a surface with the given normal.

normal is assumed to be normalized.

Implementation

V3 reflect(V3 normal) {
  final dot = dotProduct(normal);
  return _v3(
    x - (2.0*normal.x)*dot,
    y - (2.0*normal.y)*dot,
    z - (2.0*normal.z)*dot,
  );
}