diff --git a/src/point.hpp b/src/point.hpp index 920e452e0d3ec67750cf7534ba20a63a415ed641..256e518d06f6d9817a65ba295eb9b560d9327000 100644 --- a/src/point.hpp +++ b/src/point.hpp @@ -14,77 +14,58 @@ struct point { value_type y; value_type z; - constexpr point(T a, T b, T c) - : x{a}, y{b}, z{c} + constexpr point(T a, T b, T c) : + x{a}, y{b}, z{c} {} // initialize to NaN by default - constexpr point() - : x(std::numeric_limits<T>::quiet_NaN()), - y(std::numeric_limits<T>::quiet_NaN()), - z(std::numeric_limits<T>::quiet_NaN()) + constexpr point() : + x(std::numeric_limits<T>::quiet_NaN()), + y(std::numeric_limits<T>::quiet_NaN()), + z(std::numeric_limits<T>::quiet_NaN()) {} - constexpr bool is_set() const - { + constexpr bool is_set() const { return (x==x && y==y && z==z); } }; template <typename T> constexpr point<T> -operator+ ( - point<T> const& lhs, - point<T> const& rhs -) { +operator+(point<T> const& lhs, point<T> const& rhs) { return point<T>(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); } template <typename T> constexpr point<T> -operator- ( - point<T> const& lhs, - point<T> const& rhs -) { +operator-(point<T> const& lhs, point<T> const& rhs) { return point<T>(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); } template <typename T> constexpr point<T> -operator* ( - T alpha, - point<T> const& p -) { +operator*(T alpha, point<T> const& p) { return point<T>(alpha*p.x, alpha*p.y, alpha*p.z); } template <typename T> -T -norm(point<T> const& p) -{ +T norm(point<T> const& p) { return std::sqrt(p.x*p.x + p.y*p.y + p.z*p.z); } template <typename T> constexpr T -dot( - point<T> const& lhs, - point<T> const& rhs -) { +dot(point<T> const& lhs, point<T> const& rhs) { return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z; } template<typename T> -bool operator==(const point<T> &rhs, const point<T> &lhs) -{ - return (rhs.x == lhs.x) && - (rhs.y == lhs.y) && - (rhs.z == lhs.z); +bool operator==(const point<T> &rhs, const point<T> &lhs) { + return (rhs.x==lhs.x) && (rhs.y==lhs.y) && (rhs.z==lhs.z); } template<typename T> -bool operator!=(const point<T> &rhs, const point<T> &lhs) -{ +bool operator!=(const point<T> &rhs, const point<T> &lhs) { return !(rhs == lhs); } @@ -92,7 +73,6 @@ bool operator!=(const point<T> &rhs, const point<T> &lhs) } // namespace nest template <typename T> -std::ostream& operator << (std::ostream& o, nest::mc::point<T> const& p) -{ +std::ostream& operator << (std::ostream& o, nest::mc::point<T> const& p) { return o << "[" << p.x << ", " << p.y << ", " << p.z << "]"; }