Skip to content
Snippets Groups Projects
Commit 3cca4fe2 authored by Sam Yates's avatar Sam Yates Committed by GitHub
Browse files

Merge pull request #53 from bcumming/master

further style fixes in point
parents 8b39e54f 0417e072
No related branches found
No related tags found
No related merge requests found
......@@ -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 << "]";
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment