40 inline auto get_binary_pair(
double m1,
double m2,
double a,
double e,
double nu,
double G) {
45 double r = a * (1 - e * e) / (1 + e * sycl::cos(nu));
47 double x_orb = r * sycl::cos(nu);
48 double y_orb = r * sycl::sin(nu);
50 double h = sycl::sqrt(G * M * a * (1 - e * e));
51 double vx_orb = -G * M / h * sycl::sin(nu);
52 double vy_orb = G * M / h * (e + sycl::cos(nu));
54 f64_3 r_orb = {x_orb, y_orb, 0};
55 f64_3 v_orb = {vx_orb, vy_orb, 0};
57 f64_3 r1 = -m2 / M * r_orb;
58 f64_3 r2 = m1 / M * r_orb;
60 f64_3 v1 = -m2 / M * v_orb;
61 f64_3 v2 = m1 / M * v_orb;
63 return std::make_tuple(r1, r2, v1, v2);
87 static f64_3x3 rotation_matrix(
double roll,
double pitch,
double yaw) {
92 0, sycl::cos(roll), -sycl::sin(roll),
93 0, sycl::sin(roll), sycl::cos(roll)};
96 f64_3x3 Ry = {sycl::cos(pitch), 0, sycl::sin(pitch),
98 -sycl::sin(pitch), 0, sycl::cos(pitch)};
101 f64_3x3 Rz = {sycl::cos(yaw), -sycl::sin(yaw), 0,
102 sycl::sin(yaw), sycl::cos(yaw), 0,
124 static f64_3 rotate_point(
const f64_3 &point,
double roll,
double pitch,
double yaw) {
128 f64_3x3 R = rotation_matrix(roll, pitch, yaw);
134 return {rotated_point.
data[0], rotated_point.
data[1], rotated_point.
data[2]};
165 r1 = rotate_point({r1.x(), r1.y(), r1.z()}, roll, pitch, yaw);
166 r2 = rotate_point({r2.x(), r2.y(), r2.z()}, roll, pitch, yaw);
167 v1 = rotate_point({v1.x(), v1.y(), v1.z()}, roll, pitch, yaw);
168 v2 = rotate_point({v2.x(), v2.y(), v2.z()}, roll, pitch, yaw);
170 return std::make_tuple(r1, r2, v1, v2);
Matrix class based on std::array storage and mdspan.
std::array< T, m *n > data
The matrix data.
constexpr auto get_mdspan()
Get the matrix data as a mdspan.
void mat_prod(const std::mdspan< Ta, Extents1, Layout1, Accessor1 > &input1, const std::mdspan< Ta, Extents2, Layout2, Accessor2 > &input2, const std::mdspan< Tb, Extents3, Layout3, Accessor3 > &output)
Compute the product of two matrices.
auto get_binary_pair(double m1, double m2, double a, double e, double nu, double G)
Convert a binary system from Keplerian to Cartesian coordinates.
auto get_binary_rotated(double m1, double m2, double a, double e, double nu, double G, double roll, double pitch, double yaw)
Rotate a binary orbit by Euler angles and return the positions and velocities of the two objects.
constexpr T G()
get the value of G in the current unit system units