19#include <cuproj/detail/utility/cuda.hpp>
20#include <cuproj/detail/utility/floating_point.hpp>
54 return os <<
"(" << vec.x <<
"," << vec.y <<
")";
62 return detail::float_equal<T>(lhs.x, rhs.x) && detail::float_equal(lhs.y, rhs.y);
129 else if (lhs.x == rhs.x)
130 return lhs.y < rhs.y;
161vec_2d(T x, T y) -> vec_2d<T>;
169 return a.x * b.x + a.y * b.y;
178 return a.x * b.y - a.y * b.x;
188 return vec_2d<T>{::min(a.x, b.x), ::min(a.y, b.y)};
190 return vec_2d<T>{std::min(a.x, b.x), std::min(a.y, b.y)};
201 return vec_2d<T>{::max(a.x, b.x), ::max(a.y, b.y)};
203 return vec_2d<T>{std::max(a.x, b.x), std::max(a.y, b.y)};
213 return (first + second) * T{0.5};
A generic 2D vector type.
friend bool CUPROJ_HOST_DEVICE operator==(vec_2d< T > const &lhs, vec_2d< T > const &rhs)
Compare two 2D vectors for equality.
friend vec_2d< T > CUPROJ_HOST_DEVICE operator-(vec_2d< T > const &a, vec_2d< T > const &b)
Element-wise subtraction of two 2D vectors.
friend vec_2d< T > CUPROJ_HOST_DEVICE operator-(vec_2d< T > const &a)
Invert a 2D vector.
friend vec_2d< T > CUPROJ_HOST_DEVICE operator*(T const &r, vec_2d< T > vec)
Scale a 2d vector by ratio r.
friend bool CUPROJ_HOST_DEVICE operator<(vec_2d< T > const &lhs, vec_2d< T > const &rhs)
Less than operator for two 2D points.
friend std::ostream & operator<<(std::ostream &os, vec_2d< T > const &vec)
Output stream operator for vec_2d<T> for human-readable formatting.
friend vec_2d< T > CUPROJ_HOST_DEVICE operator*(vec_2d< T > vec, T const &r)
Scale a 2D vector by a factor r.
friend bool CUPROJ_HOST_DEVICE operator>=(vec_2d< T > const &lhs, vec_2d< T > const &rhs)
Greater than or equal to operator for two 2D points.
friend vec_2d< T > &CUPROJ_HOST_DEVICE operator+=(vec_2d< T > &a, vec_2d< T > const &b)
Translate a 2D point.
friend bool CUPROJ_HOST_DEVICE operator<=(vec_2d< T > const &lhs, vec_2d< T > const &rhs)
Less than or equal to operator for two 2D points.
friend bool CUPROJ_HOST_DEVICE operator>(vec_2d< T > const &lhs, vec_2d< T > const &rhs)
Greater than operator for two 2D points.
friend vec_2d< T > &CUPROJ_HOST_DEVICE operator-=(vec_2d< T > &a, vec_2d< T > const &b)
Translate a 2D point.
friend vec_2d< T > CUPROJ_HOST_DEVICE operator+(vec_2d< T > const &a, vec_2d< T > const &b)
Element-wise addition of two 2D vectors.
vec_2d< T > CUPROJ_HOST_DEVICE box_min(vec_2d< T > const &a, vec_2d< T > const &b)
Return a new vec_2d made up of the minimum x- and y-components of two input vec_2d values.
vec_2d< T > CUPROJ_HOST_DEVICE midpoint(vec_2d< T > const &first, vec_2d< T > const &second)
Compute the midpoint of first and second.
T CUPROJ_HOST_DEVICE dot(vec_2d< T > const &a, vec_2d< T > const &b)
Compute dot product of two 2D vectors.
T CUPROJ_HOST_DEVICE det(vec_2d< T > const &a, vec_2d< T > const &b)
Compute 2D determinant of a 2x2 matrix with column vectors a and b.
vec_2d< T > CUPROJ_HOST_DEVICE box_max(vec_2d< T > const &a, vec_2d< T > const &b)
Return a new vec_2d made up of the minimum x- and y-components of two input vec_2d values.