The open source OpenXR runtime
1// Copyright 2022-2024, Collabora, Inc.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Test for m_vec3_angle.
6 * @author Moshi Turner <moshiturner@protonmail.com>
7 */
8#include "xrt/xrt_defines.h"
9#include <math/m_vec3.h>
10
11
12#include "catch_amalgamated.hpp"
13
14TEST_CASE("Vec3Angle")
15{
16 float sqrt2_2 = sqrtf(2) / 2;
17 CHECK(m_vec3_angle({1, 0, 0}, {-1, 0, 0}) == Catch::Approx(M_PI));
18 CHECK(m_vec3_angle({1, 0, 0}, {0, 1, 0}) == Catch::Approx(M_PI / 2));
19 CHECK(m_vec3_angle({1, 0, 0}, {sqrt2_2, sqrt2_2, 0}) == Catch::Approx(M_PI / 4));
20}