diff --git a/util/Vector.h b/util/Vector.h index ebc944f..5fc9450 100644 --- a/util/Vector.h +++ b/util/Vector.h @@ -73,11 +73,11 @@ class Vector Vector refract(const Vector & target, double n1, double n2) const { const double n = n1 / n2; - const double cosI = dot(target); + const double cosI = -dot(target); const double sinT2 = n * n * (1.0 - cosI * cosI); if (sinT2 > 1.0) return Vector(0.0, 0.0, 0.0); - return (*this) * n - target * (n * cosI + sqrt(1.0 - sinT2)); + return (*this) * n + target * (n * cosI - sqrt(1.0 - sinT2)); } Vector getPerpendicular() const