Added bounce to vector2.hpp

pull/362/head
2shady4u 2019-12-27 14:28:42 +01:00
parent 7cbb846417
commit 9e573b6947
1 changed files with 4 additions and 0 deletions

View File

@ -176,6 +176,10 @@ struct Vector2 {
return p_vec - *this * this->dot(p_vec); return p_vec - *this * this->dot(p_vec);
} }
inline Vector2 bounce(const Vector2 &p_normal) const {
return -reflect(p_normal);
}
inline Vector2 reflect(const Vector2 &p_vec) const { inline Vector2 reflect(const Vector2 &p_vec) const {
return p_vec - *this * this->dot(p_vec) * 2.0; return p_vec - *this * this->dot(p_vec) * 2.0;
} }