Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pyRay.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
18#include "shammath/AABB.hpp"
19
20namespace shampylib {
21
22 template<class T>
23 void init_shamrock_math_Ray(py::module &m, std::string name) {
24 py::class_<shammath::Ray<T>>(m, name.c_str())
25 .def(py::init([](f64_3 origin, f64_3 direction) {
26 return std::make_unique<shammath::Ray<T>>(origin, direction);
27 }))
28 .def(
29 "origin",
30 [](shammath::Ray<T> &ray) {
31 return ray.origin;
32 })
33 .def(
34 "direction",
35 [](shammath::Ray<T> &ray) {
36 return ray.direction;
37 })
38 .def("inv_direction", [](shammath::Ray<T> &ray) {
39 return ray.inv_direction;
40 });
41 }
42
43 template void init_shamrock_math_Ray<f64_3>(py::module &m, std::string name);
44
45 template<class T>
46 void init_shamrock_math_RingRay(py::module &m, std::string name) {
47 py::class_<shammath::RingRay<T>>(m, name.c_str())
48 .def(py::init([](f64_3 center, f64 radius, f64_3 e_x, f64_3 e_y) {
49 return std::make_unique<shammath::RingRay<T>>(center, radius, e_x, e_y);
50 }))
51 .def(
52 "center",
53 [](shammath::RingRay<T> &ring_ray) {
54 return ring_ray.center;
55 })
56 .def(
57 "radius",
58 [](shammath::RingRay<T> &ring_ray) {
59 return ring_ray.radius;
60 })
61 .def(
62 "e_x",
63 [](shammath::RingRay<T> &ring_ray) {
64 return ring_ray.e_x;
65 })
66 .def("e_y", [](shammath::RingRay<T> &ring_ray) {
67 return ring_ray.e_y;
68 });
69 }
70
71 template void init_shamrock_math_RingRay<f64_3>(py::module &m, std::string name);
72
73} // namespace shampylib
double f64
Alias for double.
Pybind11 include and definitions.
Ray representation for intersection testing.
Definition AABB.hpp:34
Ring ray representation for intersection testing.
Definition AABB.hpp:67