diff options
author | Keuin <[email protected]> | 2022-04-15 12:50:23 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-15 12:50:23 +0800 |
commit | 50cd8dd3dd029ce432f8e517b4c054e75b5cfe8e (patch) | |
tree | 8fd78325d8443bb8399fbc86777ba51eabd31176 /vec.h | |
parent | 569be1744453d9e03cf6ba6360c42b9da89a596a (diff) |
Fix vec3::reflect. Add tests for vec3::reflect and vec3::is_zero.
Diffstat (limited to 'vec.h')
-rw-r--r-- | vec.h | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -88,10 +88,10 @@ struct vec3 { return *this * (1.0 / norm()); } - // Get the reflected vector. Current vector is the incoming vector, n is the normal vector (length should be 1). - vec3 reflect(const vec3 &n) const { - assert(fabs(n.mod2() - 1.0) < 1e-8); - return *this - 2.0 * dot(*this, n) * n; + // Get the reflected vector. Current vector is the normal vector (length should be 1), v is the incoming vector. + vec3 reflect(const vec3 &v) const { + assert(fabs(mod2() - 1.0) < 1e-8); + return v - (2.0 * dot(v)) * (*this); } }; |