17#include "../global/global.h"
18#include "../global/global_cuda.h"
19#include "../utils/basic_structs.h"
20#include "../utils/gpu.hpp"
43inline std::tuple<T, T, T>
rotateCoords(Real
const &x_1, Real
const &x_2, Real
const &x_3, Real
const &pitch,
48 Real
const sin_yaw = std::sin(yaw);
49 Real
const cos_yaw = (yaw == 0.5 * M_PI) ? 0 : std::cos(yaw);
50 Real
const sin_pitch = std::sin(pitch);
51 Real
const cos_pitch = (pitch == 0.5 * M_PI) ? 0 : std::cos(pitch);
54 Real
const x_1_rot = (x_1 * cos_pitch * cos_yaw) + (x_2 * sin_yaw) + (x_3 * sin_pitch * cos_yaw);
55 Real
const x_2_rot = (x_1 * cos_pitch * sin_yaw) + (x_2 * cos_yaw) + (x_3 * sin_pitch * sin_yaw);
56 Real
const x_3_rot = (x_1 * sin_pitch) + (x_3 * cos_pitch);
58 if (std::is_same<T, int>::value) {
59 return {round(x_1_rot), round(x_2_rot), round(x_3_rot)};
60 }
else if (std::is_same<T, Real>::value) {
61 return {x_1_rot, x_2_rot, x_3_rot};
79inline __device__ __host__ Real
dotProduct(Real
const &a1, Real
const &a2, Real
const &a3, Real
const &b1,
80 Real
const &b2, Real
const &b3)
82 return a1 * b1 + ((a2 * b2) + (a3 * b3));
96inline __device__ __host__ Real
SquareMagnitude(Real
const &v1, Real
const &v2, Real
const &v3)
144__device__ __host__ T
clamp(T val, T lo, T hi)
146 const T tmp = val < lo ? lo : val;
147 return tmp > hi ? hi : tmp;
std::tuple< T, T, T > rotateCoords(Real const &x_1, Real const &x_2, Real const &x_3, Real const &pitch, Real const &yaw)
Rotate cartesian coordinates. All arguments are cast to double then rotated. If the type is 'int' the...
Definition math_utilities.h:43
__device__ __host__ T clamp(T val, T lo, T hi)
When val lies within the inclusive range [lo, hi], returns val. Otherwise, return the closest value i...
Definition math_utilities.h:144
__device__ __host__ Real SquareMagnitude(Real const &v1, Real const &v2, Real const &v3)
Compute the magnitude of a vector.
Definition math_utilities.h:96
__device__ __host__ void Cyclic_Permute_Twice(hydro_utilities::VectorXYZ< Real > &vec)
Cyclically permute a Vector twice. i.e. (x,y,z) becomes (z,x,y)
Definition math_utilities.h:123
__device__ __host__ Real dotProduct(Real const &a1, Real const &a2, Real const &a3, Real const &b1, Real const &b2, Real const &b3)
Compute the dot product of a and b.
Definition math_utilities.h:79
__device__ __host__ void Cyclic_Permute_Once(hydro_utilities::VectorXYZ< Real > &vec)
Cyclically permute a Vector once. i.e. (x,y,z) becomes (y,z,x)
Definition math_utilities.h:108
A data only struct that acts as a simple 3 element vector.
Definition basic_structs.h:32
__device__ __host__ T & x() noexcept
Directly access the x, y, and z elements. Const version is needed if the object instance is declared ...
Definition basic_structs.h:68