Moving definition of reflect method.

This commit is contained in:
Patrick Shriwise 2020-08-24 10:09:24 -05:00
parent ebca9a489d
commit d99b7aab51

View file

@ -63,12 +63,10 @@ struct Position {
return std::sqrt(x*x + y*y + z*z);
}
inline Position reflect(Position n) {
const double projection = n.dot(*this);
const double magnitude = n.dot(n);
n *= (2.0 * projection / magnitude);
return *this - n;
}
//! Reflect a direction across a normal vector
//! \param[in] other Vector to reflect across
//! \result Reflected vector
Position reflect(Position n) const;
//! Rotate the position based on a rotation matrix
Position rotate(const std::vector<double>& rotation) const;
@ -96,6 +94,13 @@ inline Position operator/(Position a, Position b) { return a /= b; }
inline Position operator/(Position a, double b) { return a /= b; }
inline Position operator/(double a, Position b) { return b /= a; }
inline Position Position::reflect(Position n) const {
const double projection = n.dot(*this);
const double magnitude = n.dot(n);
n *= (2.0 * projection / magnitude);
return *this - n;
}
inline bool operator==(Position a, Position b)
{return a.x == b.x && a.y == b.y && a.z == b.z;}