Add test for m_vec3_angle

This commit is contained in:
Moses Turner 2022-11-29 03:11:05 -06:00
parent 85c0c78ac6
commit 5c68233004
2 changed files with 22 additions and 0 deletions

View file

@ -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})

View file

@ -0,0 +1,20 @@
// Copyright 2022, Collabora, Inc.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Test for m_vec3_angle.
* @author Moses Turner <moses@collabora.com>
*/
#include "xrt/xrt_defines.h"
#include <math/m_vec3.h>
#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));
}