Monado OpenXR Runtime
m_api.h File Reference

C interface to math library. More...

#include "xrt/xrt_defines.h"
Include dependency graph for m_api.h:

Go to the source code of this file.

Macros

#define MATH_GRAVITY_M_S2   (9.8066)
 Standard gravity acceleration constant. More...
 
#define MIN(A, B)   ((A) < (B) ? (A) : (B))
 Minimum of A and B. More...
 
#define MAX(A, B)   ((A) > (B) ? (A) : (B))
 Maximum of A and B. More...
 
#define CLAMP(X, A, B)   (MIN(MAX((X), (A)), (B)))
 X clamped to the range [A, B]. More...
 

Functions

size_t math_hash_string (const char *str_c, size_t length)
 Generate a hash value from the given string, trailing zero not included. More...
 
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_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_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...
 
static double math_map_ranges (double value, double from_low, double from_high, double to_low, double to_high)
 Map a number from one range to another range. More...
 
static double math_lerp (double from, double to, double amount)
 
bool math_compute_fovs (double w_total, double w_1, double horizfov_total, double h_total, double h_1, double vertfov_total, struct xrt_fov *fov)
 Perform the computations from "Computing Half-Fields-Of-View from Simpler Display Models", to get half-FOVs from things we can retrieve from other APIs. More...
 

Detailed Description

Function Documentation

◆ math_map_ranges()

static double math_map_ranges ( double  value,
double  from_low,
double  from_high,
double  to_low,
double  to_high 
)
inlinestatic

Map a number from one range to another range.

Exactly the same as Arduino's map().