53#define MATH_GRAVITY_M_S2 (9.8066)
61#define MIN(A, B) ((A) < (B) ? (A) : (B))
70#define MAX(A, B) ((A) > (B) ? (A) : (B))
78#define CLAMP(X, A, B) (MIN(MAX((X), (A)), (B)))
87#define DEG_TO_RAD(DEG) ((DEG) * M_PI / 180.)
96#define RAD_TO_DEG(RAD) ((RAD) * 180.0 / M_PI)
132math_vec3_validate(
const struct xrt_vec3 *vec3);
144math_vec3_accum(
const struct xrt_vec3 *additional,
struct xrt_vec3 *inAndOut);
156math_vec3_subtract(
const struct xrt_vec3 *subtrahend,
struct xrt_vec3 *inAndOut);
167math_vec3_scalar_mul(
float scalar,
struct xrt_vec3 *inAndOut);
194math_vec3_normalize(
struct xrt_vec3 *in);
236math_quat_from_angle_vector(
float angle_rads,
const struct xrt_vec3 *vector,
struct xrt_quat *result);
244math_quat_from_euler_angles(
const struct xrt_vec3 *angles,
struct xrt_quat *result);
252math_quat_to_euler_angles(
const struct xrt_quat *quat,
struct xrt_vec3 *euler_angles);
295math_quat_validate(
const struct xrt_quat *quat);
304math_quat_is_identity(
const struct xrt_quat *quat,
float epsilon);
313math_quat_validate_within_1_percent(
const struct xrt_quat *quat);
331math_quat_len(
const struct xrt_quat *quat);
344 return l->x * r->x + l->y * r->y + l->z * r->z + l->w * r->w;
354math_quat_normalize(
struct xrt_quat *inout);
366math_quat_ensure_normalized(
struct xrt_quat *inout);
408math_quat_integrate_velocity(
const struct xrt_quat *quat,
427math_quat_finite_difference(
const struct xrt_quat *quat0,
493math_quat_from_swing_twist(
const struct xrt_vec2 *swing,
const float twist,
struct xrt_quat *result);
502math_quat_to_swing_twist(
const struct xrt_quat *in,
struct xrt_vec2 *out_swing,
float *out_twist);
518math_quat_decompose_swing_twist(
const struct xrt_quat *in,
629math_matrix_3x3_f64_from_plus_x_z(
const struct xrt_vec3_f64 *plus_x,
706math_matrix_4x4_isometry_from_rt(
const struct xrt_matrix_3x3 *rotation,
736math_matrix_4x4_inverse_view_projection(
const struct xrt_matrix_4x4 *view,
748math_matrix_4x4_projection_vulkan_infinite_reverse(
const struct xrt_fov *fov,
767math_pose_identity(
struct xrt_pose *pose);
776math_pose_validate(
const struct xrt_pose *pose);
829math_pose_transform_point(
const struct xrt_pose *transform,
const struct xrt_vec3 *point,
struct xrt_vec3 *out_point);
843math_map_ranges(
double value,
double from_low,
double from_high,
double to_low,
double to_high)
845 return (value - from_low) * (to_high - to_low) / (from_high - from_low) + to_low;
849math_lerp(
double from,
double to,
double amount)
851 return (from * (1.0 - amount)) + (to * (amount));
905 double horizfov_total,
908 double vertfov_total,
void math_matrix_3x3_f64_identity(struct xrt_matrix_3x3_f64 *mat)
Initialize a double 3x3 matrix to the identity matrix.
Definition m_base.cpp:647
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",...
Definition m_optics.c:118
void math_matrix_3x3_identity(struct xrt_matrix_3x3 *mat)
Initialize a 3x3 matrix to the identity matrix.
Definition m_base.cpp:621
size_t math_hash_string(const char *str_c, size_t length)
Generate a hash value from the given string, trailing zero not included.
Definition m_hash.cpp:15
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.
Definition m_base.cpp:653
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.
Definition m_base.cpp:705
static float math_quat_dot(const struct xrt_quat *l, const struct xrt_quat *r)
The dot product of 2 quaternions.
Definition m_api.h:342
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.
Definition m_base.cpp:692
void math_matrix_3x3_from_quat(const struct xrt_quat *q, struct xrt_matrix_3x3 *result_out)
Initialize a 3x3 matrix from a quaternion.
Definition m_base.cpp:627
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.
Definition m_api.h:843
Wrapper header for <math.h> to ensure pi-related math constants are defined.
Describes a projection matrix fov.
Definition xrt_defines.h:499
A tightly packed 3x3 matrix of doubles.
Definition xrt_defines.h:556
A tightly packed 3x3 matrix of floats.
Definition xrt_defines.h:546
A tightly packed 4x4 matrix of floats.
Definition xrt_defines.h:573
A pose composed of a position and orientation.
Definition xrt_defines.h:479
A quaternion with single floats.
Definition xrt_defines.h:235
A 2 element vector with single floats.
Definition xrt_defines.h:268
A 3 element vector with single doubles.
Definition xrt_defines.h:301
A 3 element vector with single floats.
Definition xrt_defines.h:289
Common defines and enums for XRT.