Monado OpenXR Runtime
m_base.cpp File Reference

Base implementations for math library. More...

#include "math/m_api.h"
#include "math/m_eigen_interop.hpp"
#include "math/m_vec3.h"
#include <Eigen/Core>
#include <Eigen/Geometry>
#include <assert.h>
Include dependency graph for m_base.cpp:

Functions

static Eigen::Quaternionf copy (const struct xrt_quat &q)
 
static Eigen::Quaternionf copy (const struct xrt_quat *q)
 
static XRT_MAYBE_UNUSED Eigen::Quaterniond copyd (const struct xrt_quat &q)
 
static XRT_MAYBE_UNUSED Eigen::Quaterniond copyd (const struct xrt_quat *q)
 
static Eigen::Vector3f copy (const struct xrt_vec3 &v)
 
static Eigen::Vector3f copy (const struct xrt_vec3 *v)
 
static Eigen::Vector3d copy (const struct xrt_vec3_f64 &v)
 
static Eigen::Vector3d copy (const struct xrt_vec3_f64 *v)
 
static XRT_MAYBE_UNUSED Eigen::Vector3d copyd (const struct xrt_vec3 &v)
 
static XRT_MAYBE_UNUSED Eigen::Vector3d copyd (const struct xrt_vec3 *v)
 
static Eigen::Matrix3f copy (const struct xrt_matrix_3x3 *m)
 
static Eigen::Matrix4f copy (const struct xrt_matrix_4x4 *m)
 
bool math_vec3_validate (const struct xrt_vec3 *vec3)
 
void math_vec3_accum (const struct xrt_vec3 *additional, struct xrt_vec3 *inAndOut)
 
void math_vec3_subtract (const struct xrt_vec3 *subtrahend, struct xrt_vec3 *inAndOut)
 
void math_vec3_scalar_mul (float scalar, struct xrt_vec3 *inAndOut)
 
void math_vec3_cross (const struct xrt_vec3 *l, const struct xrt_vec3 *r, struct xrt_vec3 *result)
 
void math_vec3_normalize (struct xrt_vec3 *in)
 
void math_vec3_translation_from_isometry (const struct xrt_matrix_4x4 *transform, struct xrt_vec3 *result)
 
void math_vec3_f64_cross (const struct xrt_vec3_f64 *l, const struct xrt_vec3_f64 *r, struct xrt_vec3_f64 *result)
 
void math_vec3_f64_normalize (struct xrt_vec3_f64 *in)
 
void math_quat_from_angle_vector (float angle_rads, const struct xrt_vec3 *vector, struct xrt_quat *result)
 
void math_quat_from_euler_angles (const struct xrt_vec3 *angles, struct xrt_quat *result)
 
void math_quat_from_matrix_3x3 (const struct xrt_matrix_3x3 *mat, struct xrt_quat *result)
 
void math_quat_from_plus_x_z (const struct xrt_vec3 *plus_x, const struct xrt_vec3 *plus_z, struct xrt_quat *result)
 
static bool quat_validate (const float precision, const struct xrt_quat *quat)
 
bool math_quat_validate (const struct xrt_quat *quat)
 
bool math_quat_validate_within_1_percent (const struct xrt_quat *quat)
 
void math_quat_invert (const struct xrt_quat *quat, struct xrt_quat *out_quat)
 
float math_quat_len (const struct xrt_quat *quat)
 
void math_quat_normalize (struct xrt_quat *inout)
 
bool math_quat_ensure_normalized (struct xrt_quat *inout)
 
void math_quat_rotate (const struct xrt_quat *left, const struct xrt_quat *right, struct xrt_quat *result)
 
void math_quat_unrotate (const struct xrt_quat *left, const struct xrt_quat *right, struct xrt_quat *result)
 
void math_quat_rotate_vec3 (const struct xrt_quat *left, const struct xrt_vec3 *right, struct xrt_vec3 *result)
 
void math_quat_rotate_derivative (const struct xrt_quat *quat, const struct xrt_vec3 *deriv, struct xrt_vec3 *result)
 
void math_quat_slerp (const struct xrt_quat *left, const struct xrt_quat *right, float t, struct xrt_quat *result)
 
void math_quat_from_swing (const struct xrt_vec2 *swing, struct xrt_quat *result)
 
void math_quat_from_swing_twist (const struct xrt_vec2 *swing, const float twist, struct xrt_quat *result)
 
void math_matrix_3x3_identity (struct xrt_matrix_3x3 *mat)
 Initialize a 3x3 matrix to the identity matrix. More...
 
void math_matrix_3x3_from_quat (const struct xrt_quat *q, struct xrt_matrix_3x3 *result_out)
 Initialize a 3x3 matrix from a quaternion. More...
 
void math_matrix_3x3_f64_identity (struct xrt_matrix_3x3_f64 *mat)
 Initialize a double 3x3 matrix to the identity matrix. More...
 
void math_matrix_3x3_f64_transform_vec3_f64 (const struct xrt_matrix_3x3_f64 *left, const struct xrt_vec3_f64 *right, struct xrt_vec3_f64 *result_out)
 Transform a double vec3 by a 3x3 double matrix. More...
 
void math_matrix_3x3_f64_from_plus_x_z (const struct xrt_vec3_f64 *plus_x, const struct xrt_vec3_f64 *plus_z, struct xrt_matrix_3x3_f64 *result)
 
void math_matrix_3x3_rotation_from_isometry (const struct xrt_matrix_4x4 *isometry, struct xrt_matrix_3x3 *result)
 
void math_matrix_3x3_transform_vec3 (const struct xrt_matrix_3x3 *left, const struct xrt_vec3 *right, struct xrt_vec3 *result_out)
 Transform a vec3 by a 3x3 matrix. More...
 
void math_matrix_4x4_transform_vec3 (const struct xrt_matrix_4x4 *left, const struct xrt_vec3 *right, struct xrt_vec3 *result_out)
 Transform a vec3 by a 4x4 matrix, extending the vector with w = 1.0. More...
 
void math_matrix_3x3_multiply (const struct xrt_matrix_3x3 *left, const struct xrt_matrix_3x3 *right, struct xrt_matrix_3x3 *result_out)
 
void math_matrix_3x3_inverse (const struct xrt_matrix_3x3 *in, struct xrt_matrix_3x3 *result)
 
void math_matrix_3x3_transpose (const struct xrt_matrix_3x3 *in, struct xrt_matrix_3x3 *result)
 
void math_matrix_4x4_identity (struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_multiply (const struct xrt_matrix_4x4 *left, const struct xrt_matrix_4x4 *right, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_inverse (const struct xrt_matrix_4x4 *in, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_transpose (const struct xrt_matrix_4x4 *in, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_isometry_inverse (const struct xrt_matrix_4x4 *in, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_view_from_pose (const struct xrt_pose *pose, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_isometry_from_rt (const struct xrt_matrix_3x3 *rotation, const struct xrt_vec3 *translation, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_isometry_from_pose (const struct xrt_pose *pose, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_model (const struct xrt_pose *pose, const struct xrt_vec3 *size, struct xrt_matrix_4x4 *result)
 
void math_matrix_4x4_inverse_view_projection (const struct xrt_matrix_4x4 *view, const struct xrt_matrix_4x4 *projection, struct xrt_matrix_4x4 *result)
 
void m_mat4_f64_identity (struct xrt_matrix_4x4_f64 *result)
 
void m_mat4_f64_invert (const struct xrt_matrix_4x4_f64 *matrix, struct xrt_matrix_4x4_f64 *result)
 
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)
 
void m_mat4_f64_orientation (const struct xrt_quat *quat, struct xrt_matrix_4x4_f64 *result)
 
void m_mat4_f64_model (const struct xrt_pose *pose, const struct xrt_vec3 *size, struct xrt_matrix_4x4_f64 *result)
 
void m_mat4_f64_view (const struct xrt_pose *pose, struct xrt_matrix_4x4_f64 *result)
 
bool math_pose_validate (const struct xrt_pose *pose)
 
void math_pose_invert (const struct xrt_pose *pose, struct xrt_pose *outPose)
 
void math_pose_from_isometry (const struct xrt_matrix_4x4 *transform, struct xrt_pose *result)
 
void math_pose_interpolate (const struct xrt_pose *a, const struct xrt_pose *b, float t, struct xrt_pose *outPose)
 
void math_pose_identity (struct xrt_pose *pose)
 
static Eigen::Vector3f transform_point (const xrt_pose &transform, const xrt_vec3 &point)
 Return the result of transforming a point by a pose/transform. More...
 
static xrt_pose transform_pose (const xrt_pose &transform, const xrt_pose &pose)
 Return the result of transforming a pose by a pose/transform. More...
 
void math_pose_transform (const struct xrt_pose *transform, const struct xrt_pose *pose, struct xrt_pose *outPose)
 
void math_pose_transform_point (const struct xrt_pose *transform, const struct xrt_vec3 *point, struct xrt_vec3 *out_point)
 

Detailed Description

Function Documentation

◆ transform_point()

static Eigen::Vector3f transform_point ( const xrt_pose transform,
const xrt_vec3 point 
)
inlinestatic

Return the result of transforming a point by a pose/transform.

References xrt::auxiliary::math::map_vec3(), xrt::auxiliary::math::orientation(), and xrt::auxiliary::math::position().

Referenced by transform_pose().

◆ transform_pose()

static xrt_pose transform_pose ( const xrt_pose transform,
const xrt_pose pose 
)
inlinestatic

Return the result of transforming a pose by a pose/transform.

References xrt::auxiliary::math::orientation(), xrt::auxiliary::math::position(), and transform_point().