Monado OpenXR Runtime
m_matrix_4x4_f64.h
Go to the documentation of this file.
1// Copyright 2019-2021, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief C matrix 4x4 f64 math library.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 *
8 * @see xrt_matrix_4x4_f64
9 * @ingroup aux_math
10 */
11
12#pragma once
13
14#include "xrt/xrt_defines.h"
15
16#include "m_mathinclude.h"
17
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23
24/*!
25 * Initialize Matrix4x4 F64 with identity.
26 *
27 * @relates xrt_matrix_4x4_f64
28 * @ingroup aux_math
29 */
30void
32
33/*!
34 * Invert a Matrix4x4 F64.
35 *
36 * @relates xrt_matrix_4x4_f64
37 * @ingroup aux_math
38 */
39void
40m_mat4_f64_invert(const struct xrt_matrix_4x4_f64 *matrix, struct xrt_matrix_4x4_f64 *result);
41
42/*!
43 * Multiply Matrix4x4 F64.
44 *
45 * @relates xrt_matrix_4x4_f64
46 * @ingroup aux_math
47 */
48void
50 const struct xrt_matrix_4x4_f64 *right,
51 struct xrt_matrix_4x4_f64 *result);
52
53/*!
54 * Initialize Matrix4x4 F64 with a orientation.
55 *
56 * @relates xrt_matrix_4x4_f64
57 * @ingroup aux_math
58 */
59void
60m_mat4_f64_orientation(const struct xrt_quat *quat, struct xrt_matrix_4x4_f64 *result);
61
62/*!
63 * Initialize Matrix4x4 F64 with a pose and size that can be used as a model matrix.
64 *
65 * @relates xrt_matrix_4x4_f64
66 * @ingroup aux_math
67 */
68void
69m_mat4_f64_model(const struct xrt_pose *pose, const struct xrt_vec3 *size, struct xrt_matrix_4x4_f64 *result);
70
71/*!
72 * Initialize Matrix4x4 F64 with a pose that can be used as a view martix.
73 *
74 * @relates xrt_matrix_4x4_f64
75 * @ingroup aux_math
76 */
77void
78m_mat4_f64_view(const struct xrt_pose *pose, const struct xrt_vec3 *size, struct xrt_matrix_4x4_f64 *result);
79
80
81#ifdef __cplusplus
82}
83
84
85static inline struct xrt_matrix_4x4_f64 // Until clang-format-11 is on the CI.
86operator*(const struct xrt_matrix_4x4_f64 &a, const struct xrt_matrix_4x4_f64 &b)
87{
88 struct xrt_matrix_4x4_f64 ret = {{0}};
89 m_mat4_f64_multiply(&l, &r, &ret);
90 return ret;
91}
92
93static inline void
94operator*=(struct xrt_matrix_4x4_f64 &a, const struct xrt_matrix_4x4_f64 &b)
95{
96 a = a * b;
97}
98
99
100#endif
void m_mat4_f64_identity(struct xrt_matrix_4x4_f64 *result)
Initialize Matrix4x4 F64 with identity.
Definition: m_base.cpp:848
void m_mat4_f64_orientation(const struct xrt_quat *quat, struct xrt_matrix_4x4_f64 *result)
Initialize Matrix4x4 F64 with a orientation.
Definition: m_base.cpp:872
void m_mat4_f64_view(const struct xrt_pose *pose, const struct xrt_vec3 *size, struct xrt_matrix_4x4_f64 *result)
Initialize Matrix4x4 F64 with a pose that can be used as a view martix.
void m_mat4_f64_model(const struct xrt_pose *pose, const struct xrt_vec3 *size, struct xrt_matrix_4x4_f64 *result)
Initialize Matrix4x4 F64 with a pose and size that can be used as a model matrix.
Definition: m_base.cpp:878
void m_mat4_f64_invert(const struct xrt_matrix_4x4_f64 *matrix, struct xrt_matrix_4x4_f64 *result)
Invert a Matrix4x4 F64.
Definition: m_base.cpp:854
void m_mat4_f64_multiply(const struct xrt_matrix_4x4_f64 *left, const struct xrt_matrix_4x4_f64 *right, struct xrt_matrix_4x4_f64 *result)
Multiply Matrix4x4 F64.
Definition: m_base.cpp:861
Wrapper header for <math.h> to ensure pi-related math constants are defined.
A tightly packed 4x4 matrix of double.
Definition: xrt_defines.h:570
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
A quaternion with single floats.
Definition: xrt_defines.h:216
A 3 element vector with single floats.
Definition: xrt_defines.h:271
Common defines and enums for XRT.