diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3812a7f6a..662512d07 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,6 +27,7 @@ set(tests tests_vector tests_worker tests_pose + tests_vec3_angle ) if(XRT_HAVE_D3D11) list(APPEND tests tests_aux_d3d_d3d11 tests_comp_client_d3d11) @@ -68,6 +69,7 @@ target_link_libraries(tests_rational PRIVATE aux_math) target_link_libraries(tests_pose PRIVATE aux_math) target_link_libraries(tests_quat_change_of_basis PRIVATE aux_math) target_link_libraries(tests_quat_swing_twist PRIVATE aux_math) +target_link_libraries(tests_vec3_angle PRIVATE aux_math) target_include_directories(tests_quat_change_of_basis SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) target_include_directories(tests_quat_swing_twist SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) diff --git a/tests/tests_vec3_angle.cpp b/tests/tests_vec3_angle.cpp new file mode 100644 index 000000000..32c248887 --- /dev/null +++ b/tests/tests_vec3_angle.cpp @@ -0,0 +1,20 @@ +// Copyright 2022, Collabora, Inc. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Test for m_vec3_angle. + * @author Moses Turner + */ +#include "xrt/xrt_defines.h" +#include + + +#include "catch/catch.hpp" + +TEST_CASE("Vec3Angle") +{ + float sqrt2_2 = sqrtf(2) / 2; + CHECK(m_vec3_angle({1, 0, 0}, {-1, 0, 0}) == Approx(M_PI)); + CHECK(m_vec3_angle({1, 0, 0}, {0, 1, 0}) == Approx(M_PI / 2)); + CHECK(m_vec3_angle({1, 0, 0}, {sqrt2_2, sqrt2_2, 0}) == Approx(M_PI / 4)); +}