Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:24

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 // Project include(s)
0010 #include "detray/utils/unit_vectors.hpp"
0011 
0012 // Detray test include(s)
0013 #include "detray/test/framework/types.hpp"
0014 
0015 // Google Test include(s)
0016 #include <gtest/gtest.h>
0017 
0018 using namespace detray;
0019 
0020 using transform3 = test::transform3;
0021 using vector3 = typename transform3::vector3;
0022 using scalar = test::scalar;
0023 
0024 GTEST_TEST(detray_utils, curvilinear_unit_vectors) {
0025   constexpr const scalar tolerance = 1e-5f;
0026 
0027   // General case
0028   vector3 w{2.f, 3.f, 4.f};
0029 
0030   auto uv = unit_vectors<vector3>().make_curvilinear_unit_vectors(w);
0031   auto u = uv[0];
0032   auto v = uv[1];
0033 
0034   EXPECT_NEAR(u[0], -3.f / vector::perp(w), tolerance);
0035   EXPECT_NEAR(u[1], 2.f / vector::perp(w), tolerance);
0036   EXPECT_NEAR(u[2], 0.f, tolerance);
0037 
0038   const vector3 test_v = vector::normalize(vector::cross(w, u));
0039   EXPECT_NEAR(v[0], test_v[0], tolerance);
0040   EXPECT_NEAR(v[1], test_v[1], tolerance);
0041   EXPECT_NEAR(v[2], test_v[2], tolerance);
0042 
0043   // Special case where w is aligned with z axis
0044   w = {0.f, 0.f, 23.f};
0045 
0046   uv = unit_vectors<vector3>().make_curvilinear_unit_vectors(w);
0047   u = uv[0];
0048   v = uv[1];
0049 
0050   EXPECT_NEAR(u[0], 1.f, tolerance);
0051   EXPECT_NEAR(u[1], 0.f, tolerance);
0052   EXPECT_NEAR(u[2], 0.f, tolerance);
0053 
0054   EXPECT_NEAR(v[0], 0.f, tolerance);
0055   EXPECT_NEAR(v[1], 1.f, tolerance);
0056   EXPECT_NEAR(v[2], 0.f, tolerance);
0057 }