File indexing completed on 2026-05-27 07:24:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/geometry/coordinates/cartesian3D.hpp"
0011
0012 #include "detray/definitions/units.hpp"
0013 #include "detray/geometry/concepts.hpp"
0014
0015
0016 #include "detray/test/framework/types.hpp"
0017
0018
0019 #include <gtest/gtest.h>
0020
0021 using namespace detray;
0022
0023 using test_algebra = test::algebra;
0024 using scalar = test::scalar;
0025 using point3 = test::point3;
0026 using vector3 = test::vector3;
0027 using transform3 = test::transform3;
0028
0029 const scalar isclose{1e-5f};
0030
0031
0032 GTEST_TEST(detray_coordinates, cartesian3D) {
0033
0034 const vector3 z = {0.f, 0.f, 1.f};
0035 const vector3 x = {1.f, 0.f, 0.f};
0036 const point3 t = {2.f, 3.f, 4.f};
0037 const transform3 trf(t, z, x);
0038 const point3 global1 = {4.f, 7.f, 5.f};
0039 const vector3 mom = {1.f, 2.f, 3.f};
0040 const vector3 d = vector::normalize(mom);
0041
0042 const cartesian3D<test_algebra> c3;
0043
0044 static_assert(concepts::coordinate_frame<cartesian3D<test_algebra>>);
0045 static_assert(concepts::rectilinear_frame<cartesian3D<test_algebra>>);
0046
0047
0048 const point3 local = c3.global_to_local_3D(trf, global1, d);
0049
0050
0051 ASSERT_NEAR(local[0], 2.f, isclose);
0052 ASSERT_NEAR(local[1], 4.f, isclose);
0053 ASSERT_NEAR(local[2], 1.f, isclose);
0054
0055
0056 const point3 global2 = c3.local_to_global(trf, local);
0057
0058
0059 ASSERT_NEAR(global1[0], global2[0], isclose);
0060 ASSERT_NEAR(global1[1], global2[1], isclose);
0061 ASSERT_NEAR(global1[2], global2[2], isclose);
0062 }