12#ifndef EBGEOMETRY_VEC_HPP
13#define EBGEOMETRY_VEC_HPP
39 static_assert(std::is_floating_point_v<T>,
"Vec2T<T>: T must be a floating-point type");
63 constexpr
Vec2T(const T& a_x, const T& a_y) noexcept;
77 operator[](
size_t i) noexcept;
85 inline constexpr const T&
86 operator[](
size_t i) const noexcept;
93 inline static constexpr
Vec2T<T>
101 inline static constexpr
Vec2T<T>
109 inline static constexpr
Vec2T<T>
117 inline static constexpr
Vec2T<T>
125 inline static constexpr
Vec2T<T>
134 operator=(const
Vec2T& a_other) noexcept = default;
142 inline constexpr
Vec2T<T>
143 operator+(const
Vec2T& a_other) const noexcept;
151 inline constexpr
Vec2T<T>
152 operator-(const
Vec2T& a_other) const noexcept;
159 inline constexpr
Vec2T<T>
160 operator-() const noexcept;
168 inline constexpr
Vec2T<T>
169 operator*(const T& s) const noexcept;
177 inline constexpr
Vec2T<T>
178 operator/(const T& s) const noexcept;
186 inline constexpr
Vec2T<T>&
187 operator+=(const
Vec2T& a_other) noexcept;
195 inline constexpr
Vec2T<T>&
196 operator-=(const
Vec2T& a_other) noexcept;
204 inline constexpr
Vec2T<T>&
205 operator*=(const T& s) noexcept;
213 inline constexpr
Vec2T<T>&
214 operator/=(const T& s) noexcept;
260 static_assert(std::is_floating_point_v<T>,
"Vec3T<T>: T must be a floating-point type");
286 constexpr
Vec3T(const T& a_x, const T& a_y, const T& a_z) noexcept;
298 inline static constexpr
Vec3T<T>
306 inline static constexpr
Vec3T<T>
315 inline static constexpr
Vec3T<T>
316 unit(const
size_t a_dir) noexcept;
323 inline static constexpr
Vec3T<T>
331 inline static constexpr
Vec3T<T>
339 inline static constexpr
Vec3T<T>
351 inline constexpr
bool
352 lessLX(const
Vec3T<T>& u) const noexcept;
361 operator[](
size_t i) noexcept;
369 inline constexpr const T&
370 operator[](
size_t i) const noexcept;
378 inline constexpr
bool
379 operator==(const
Vec3T<T>& u) const noexcept;
387 inline constexpr
bool
388 operator!=(const
Vec3T<T>& u) const noexcept;
400 operator<(const
Vec3T<T>& u) const noexcept = delete;
402 operator>(const
Vec3T<T>& u) const noexcept = delete;
404 operator<=(const
Vec3T<T>& u) const noexcept = delete;
406 operator>=(const
Vec3T<T>& u) const noexcept = delete;
415 operator=(const
Vec3T<T>& u) noexcept = default;
423 inline constexpr
Vec3T<T>
424 operator+(const
Vec3T<T>& u) const noexcept;
432 inline constexpr
Vec3T<T>
433 operator-(const
Vec3T<T>& u) const noexcept;
440 inline constexpr
Vec3T<T>
441 operator+() const noexcept;
448 inline constexpr
Vec3T<T>
449 operator-() const noexcept;
458 inline constexpr
Vec3T<T>
459 operator*(const T& s) const noexcept;
468 inline constexpr
Vec3T<T>
469 operator*(const
Vec3T<T>& s) const noexcept;
477 inline constexpr
Vec3T<T>
478 operator/(const T& s) const noexcept;
486 inline constexpr
Vec3T<T>
487 operator/(const
Vec3T<T>& v) const noexcept;
495 inline constexpr
Vec3T<T>&
496 operator+=(const
Vec3T<T>& u) noexcept;
504 inline constexpr
Vec3T<T>&
505 operator-=(const
Vec3T<T>& u) noexcept;
513 inline constexpr
Vec3T<T>&
514 operator*=(const T& s) noexcept;
522 inline constexpr
Vec3T<T>&
523 operator/=(const T& s) noexcept;
531 inline constexpr
Vec3T<T>
550 minDir(const
bool a_doAbs) const noexcept;
561 maxDir(const
bool a_doAbs) const noexcept;
595template <class R, typename T, std::enable_if_t<std::is_arithmetic_v<R>,
int> = 0>
597inline constexpr
Vec2T<T>
598operator*(const R& s, const
Vec2T<T>& a_other) noexcept;
609template <class R, typename T, std::enable_if_t<std::is_arithmetic_v<R>,
int> = 0>
611inline constexpr
Vec2T<T>
612operator/(const R& s, const
Vec2T<T>& a_other) noexcept;
673template <class R, typename T, std::enable_if_t<std::is_arithmetic_v<R>,
int> = 0>
675inline constexpr
Vec3T<T>
676operator*(const R& s, const
Vec3T<T>& u) noexcept;
687template <class R, typename T, std::enable_if_t<std::is_arithmetic_v<R>,
int> = 0>
689inline constexpr
Vec3T<T>
690operator/(const R& s, const
Vec3T<T>& u) noexcept;
703inline constexpr
Vec3T<T>
717inline constexpr
Vec3T<T>
730inline constexpr
Vec3T<T>
754inline constexpr
Vec3T<T>
768static_assert(std::is_trivially_copyable_v<
Vec2T<
float>>, "
Vec2T<
float> must be trivially copyable");
769static_assert(std::is_trivially_copyable_v<
Vec2T<
double>>, "
Vec2T<
double> must be trivially copyable");
770static_assert(std::is_trivially_copyable_v<
Vec3T<
float>>, "
Vec3T<
float> must be trivially copyable");
771static_assert(std::is_trivially_copyable_v<
Vec3T<
double>>, "
Vec3T<
double> must be trivially copyable");
772static_assert(std::is_trivially_default_constructible_v<
Vec2T<
float>>,
773 "
Vec2T<
float> must be trivially default constructible");
774static_assert(std::is_trivially_default_constructible_v<
Vec2T<
double>>,
775 "
Vec2T<
double> must be trivially default constructible");
776static_assert(std::is_trivially_default_constructible_v<
Vec3T<
float>>,
777 "
Vec3T<
float> must be trivially default constructible");
778static_assert(std::is_trivially_default_constructible_v<
Vec3T<
double>>,
779 "
Vec3T<
double> must be trivially default constructible");
783#include "EBGeometry_VecImplem.hpp"
A fixed-size array that compiles for both host and device.
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Utility macros for EBGeometry.
Scalar helpers and numeric limits that compile for both host and device.
Two-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:37
constexpr T dot(const Vec2T &a_other) const noexcept
Dot product.
static constexpr Vec2T< T > infinity() noexcept
Return a vector with infinite components.
static constexpr Vec2T< T > zeros() noexcept
Return a vector with x = y = 0.
constexpr T length2() const noexcept
Compute squared vector length.
static constexpr Vec2T< T > min() noexcept
Return the most-negative representable vector.
Array< T, 2 > m_X
Vector components.
Definition EBGeometry_Vec.hpp:246
Vec2T() noexcept=default
Default constructor. Leaves the components uninitialized.
T length() const noexcept
Compute length of vector.
static constexpr Vec2T< T > max() noexcept
Return the most-positive representable vector.
static constexpr Vec2T< T > ones() noexcept
Return a vector with x = y = 1.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Vec3T() noexcept=default
Default constructor. Leaves the components uninitialized.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
constexpr Vec3T< T > clamp(const Vec3T< T > &v, const Vec3T< T > &lo, const Vec3T< T > &hi) noexcept
Component-wise clamp of a 3D vector.
constexpr Vec3T< T > cross(const Vec3T< T > &u, const Vec3T< T > &v) noexcept
Cross product of two 3D vectors.
Fixed-size array with host- and device-callable members.
Definition EBGeometry_Array.hpp:33