Monado OpenXR Runtime
Loading...
Searching...
No Matches
openvr_math.hpp
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Implementation of math utilities for OpenVR.
6 *
7 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
8 * @ingroup openvr_common
9 */
10
11#pragma once
12
13#include "math/m_api.h"
14
15#include "openvr_interfaces_unified.h"
16
17
18namespace xrt::state_trackers::openvr {
19
20/*!
21 * Converts an xrt_pose to an OpenVR HmdMatrix34, which is used for representing poses in OpenVR. This involves
22 * converting the xrt_pose to a 4x4 isometry matrix, and then dropping the last row to fit it into the 3x4 OpenVR
23 * format.
24 *
25 * @param pose The xrt_pose to convert.
26 * @param openvr_mat The output OpenVR HmdMatrix34_t to write the result into.
27 */
28void
29xrt_pose_to_openvr_hmd_matrix34(const xrt_pose &pose, vr::HmdMatrix34_t &openvr_mat);
30
31/*!
32 * Converts a 4x4 matrix in column-major format (as used by xrt_matrix_4x4) to an OpenVR HmdMatrix34, which is a
33 * 3x4 matrix in row-major format. This involves dropping the last row of the 4x4 matrix, and transposing the data to
34 * convert from column-major to row-major.
35 *
36 * @param mat The xrt_matrix_4x4 to convert.
37 * @param openvr_mat The output OpenVR HmdMatrix34_t to write the result into.
38 */
39void
40xrt_matrix_4x4_to_openvr_hmd_matrix34(const xrt_matrix_4x4 &mat, vr::HmdMatrix34_t &openvr_mat);
41
42/*!
43 * Sets an OpenVR HmdMatrix34_t to the identity matrix. This is a 3x4 matrix where the upper-left 3x3 portion is the
44 * identity rotation, and the rightmost column is the zero translation.
45 *
46 * @param mat The OpenVR HmdMatrix34_t to set to the identity matrix.
47 */
48void
49openvr_hmd_matrix34_identity(vr::HmdMatrix34_t &mat);
50
51}; // namespace xrt::state_trackers::openvr
C interface to math library.
void openvr_hmd_matrix34_identity(vr::HmdMatrix34_t &mat)
Sets an OpenVR HmdMatrix34_t to the identity matrix.
Definition openvr_math.cpp:39
void xrt_matrix_4x4_to_openvr_hmd_matrix34(const xrt_matrix_4x4 &mat, vr::HmdMatrix34_t &openvr_mat)
Converts a 4x4 matrix in column-major format (as used by xrt_matrix_4x4) to an OpenVR HmdMatrix34,...
Definition openvr_math.cpp:28
void xrt_pose_to_openvr_hmd_matrix34(const xrt_pose &pose, vr::HmdMatrix34_t &openvr_mat)
Converts an xrt_pose to an OpenVR HmdMatrix34, which is used for representing poses in OpenVR.
Definition openvr_math.cpp:19
A tightly packed 4x4 matrix of floats.
Definition xrt_defines.h:586
A pose composed of a position and orientation.
Definition xrt_defines.h:492