19#include <cuspatial/cuda_utils.hpp>
20#include <cuspatial/detail/utility/floating_point.cuh>
51 friend std::ostream&
operator<<(std::ostream& os, cuspatial::vec_3d<T>
const& vec)
53 return os <<
"(" << vec.x <<
"," << vec.y <<
"," << vec.z <<
")";
59 friend bool CUSPATIAL_HOST_DEVICE
operator==(vec_3d<T>
const& lhs, vec_3d<T>
const& rhs)
61 return detail::float_equal<T>(lhs.x, rhs.x) && detail::float_equal(lhs.y, rhs.y) &&
62 detail::float_equal(lhs.z, rhs.z);
68 friend vec_3d<T> CUSPATIAL_HOST_DEVICE
operator+(vec_3d<T>
const& a, vec_3d<T>
const& b)
70 return vec_3d<T>{a.x + b.x, a.y + b.y, a.z + b.z};
76 friend vec_3d<T> CUSPATIAL_HOST_DEVICE
operator-(vec_3d<T>
const& a, vec_3d<T>
const& b)
78 return vec_3d<T>{a.x - b.x, a.y - b.y, a.z - b.z};
84 friend vec_3d<T> CUSPATIAL_HOST_DEVICE
operator-(vec_3d<T>
const& a)
86 return vec_3d<T>{-a.x, -a.y, -a.z};
92 friend vec_3d<T> CUSPATIAL_HOST_DEVICE
operator*(vec_3d<T> vec, T
const& r)
94 return vec_3d<T>{vec.x * r, vec.y * r, vec.z * r};
100 friend vec_3d<T> CUSPATIAL_HOST_DEVICE
operator*(T
const& r, vec_3d<T> vec) {
return vec * r; }
105 friend vec_3d<T>& CUSPATIAL_HOST_DEVICE
operator+=(vec_3d<T>& a, vec_3d<T>
const& b)
116 friend vec_3d<T>& CUSPATIAL_HOST_DEVICE
operator-=(vec_3d<T>& a, vec_3d<T>
const& b)
126 friend bool CUSPATIAL_HOST_DEVICE
operator<(vec_3d<T>
const& lhs, vec_3d<T>
const& rhs)
128 if (lhs.x < rhs.x)
return true;
129 if (lhs.x > rhs.x)
return false;
130 if (lhs.y < rhs.y)
return true;
131 if (lhs.y > rhs.y)
return false;
132 return lhs.z < rhs.z;
138 friend bool CUSPATIAL_HOST_DEVICE
operator>(vec_3d<T>
const& lhs, vec_3d<T>
const& rhs)
146 friend bool CUSPATIAL_HOST_DEVICE
operator<=(vec_3d<T>
const& lhs, vec_3d<T>
const& rhs)
154 friend bool CUSPATIAL_HOST_DEVICE
operator>=(vec_3d<T>
const& lhs, vec_3d<T>
const& rhs)
162vec_3d(T x, T y, T z) -> vec_3d<T>;
168T CUSPATIAL_HOST_DEVICE
dot(vec_3d<T>
const& a, vec_3d<T>
const& b)
170 return a.x * b.x + a.y * b.y + a.z * b.z;
179vec_3d<T> CUSPATIAL_HOST_DEVICE
cross(vec_3d<T>
const& a, vec_3d<T>
const& b)
181 return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x};
A generic 3D vector type.
friend vec_3d< T > &CUSPATIAL_HOST_DEVICE operator-=(vec_3d< T > &a, vec_3d< T > const &b)
Translate a 3D point.
friend vec_3d< T > CUSPATIAL_HOST_DEVICE operator-(vec_3d< T > const &a)
Invert a 3D vector.
friend bool CUSPATIAL_HOST_DEVICE operator==(vec_3d< T > const &lhs, vec_3d< T > const &rhs)
Compare two 3D vectors for equality.
friend std::ostream & operator<<(std::ostream &os, cuspatial::vec_3d< T > const &vec)
Output stream operator for vec_3d<T> for human-readable formatting.
friend vec_3d< T > CUSPATIAL_HOST_DEVICE operator-(vec_3d< T > const &a, vec_3d< T > const &b)
Element-wise subtraction of two 3D vectors.
friend bool CUSPATIAL_HOST_DEVICE operator>=(vec_3d< T > const &lhs, vec_3d< T > const &rhs)
Greater than or equal to operator for two 3D points.
friend vec_3d< T > &CUSPATIAL_HOST_DEVICE operator+=(vec_3d< T > &a, vec_3d< T > const &b)
Translate a 3D point.
friend bool CUSPATIAL_HOST_DEVICE operator<=(vec_3d< T > const &lhs, vec_3d< T > const &rhs)
Less than or equal to operator for two 3D points.
friend bool CUSPATIAL_HOST_DEVICE operator<(vec_3d< T > const &lhs, vec_3d< T > const &rhs)
Less than operator for two 3D points.
T CUSPATIAL_HOST_DEVICE dot(vec_2d< T > const &a, vec_2d< T > const &b)
Compute dot product of two 2D vectors.
friend vec_3d< T > CUSPATIAL_HOST_DEVICE operator+(vec_3d< T > const &a, vec_3d< T > const &b)
Element-wise addition of two 3D vectors.
vec_3d< T > CUSPATIAL_HOST_DEVICE cross(vec_3d< T > const &a, vec_3d< T > const &b)
Compute cross product of two 3D vectors.
friend vec_3d< T > CUSPATIAL_HOST_DEVICE operator*(vec_3d< T > vec, T const &r)
Scale a 3D vector by a factor r.
friend bool CUSPATIAL_HOST_DEVICE operator>(vec_3d< T > const &lhs, vec_3d< T > const &rhs)
Greater than operator for two 3D points.
friend vec_3d< T > CUSPATIAL_HOST_DEVICE operator*(T const &r, vec_3d< T > vec)
Scale a 3d vector by ratio r.