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);
206math_vec3_convert_from_opencv(
const struct xrt_vec3 *in,
struct xrt_vec3 *out);
260math_quat_from_angle_vector(
float angle_rads,
const struct xrt_vec3 *vector,
struct xrt_quat *result);
268math_quat_from_euler_angles(
const struct xrt_vec3 *angles,
struct xrt_quat *result);
276math_quat_to_euler_angles(
const struct xrt_quat *quat,
struct xrt_vec3 *euler_angles);
319math_quat_validate(
const struct xrt_quat *quat);
328math_quat_is_identity(
const struct xrt_quat *quat,
float epsilon);
337math_quat_validate_within_1_percent(
const struct xrt_quat *quat);
355math_quat_len(
const struct xrt_quat *quat);
368 return l->x * r->x + l->y * r->y + l->z * r->z + l->w * r->w;
378math_quat_normalize(
struct xrt_quat *inout);
390math_quat_ensure_normalized(
struct xrt_quat *inout);
432math_quat_integrate_velocity(
const struct xrt_quat *quat,
451math_quat_finite_difference(
const struct xrt_quat *quat0,
517math_quat_from_swing_twist(
const struct xrt_vec2 *swing,
const float twist,
struct xrt_quat *result);
526math_quat_to_swing_twist(
const struct xrt_quat *in,
struct xrt_vec2 *out_swing,
float *out_twist);
542math_quat_decompose_swing_twist(
const struct xrt_quat *in,
653math_matrix_3x3_f64_from_plus_x_z(
const struct xrt_vec3_f64 *plus_x,
730math_matrix_4x4_isometry_from_rt(
const struct xrt_matrix_3x3 *rotation,
760math_matrix_4x4_inverse_view_projection(
const struct xrt_matrix_4x4 *view,
772math_matrix_4x4_projection_vulkan_infinite_reverse(
const struct xrt_fov *fov,
791math_pose_identity(
struct xrt_pose *pose);
800math_pose_validate(
const struct xrt_pose *pose);
853math_pose_transform_point(
const struct xrt_pose *transform,
const struct xrt_vec3 *point,
struct xrt_vec3 *out_point);
865math_pose_convert_from_opencv(
const struct xrt_pose *in,
struct xrt_pose *out);
879math_map_ranges(
double value,
double from_low,
double from_high,
double to_low,
double to_high)
881 return (value - from_low) * (to_high - to_low) / (from_high - from_low) + to_low;
885math_lerp(
double from,
double to,
double amount)
887 return (from * (1.0 - amount)) + (to * (amount));
941 double horizfov_total,
944 double vertfov_total,
971 const struct xrt_quat *canted_view_orientation,
972 struct xrt_fov *out_parallelized_fov);
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:663
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:119
void math_matrix_3x3_identity(struct xrt_matrix_3x3 *mat)
Initialize a 3x3 matrix to the identity matrix.
Definition m_base.cpp:637
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:669
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:721
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:366
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:708
void math_compute_parallelized_fov(const struct xrt_fov *fov, const struct xrt_quat *canted_view_orientation, struct xrt_fov *out_parallelized_fov)
Compute the FOV to use when parallelizing canted views.
Definition m_optics.c:165
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:643
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:879
Wrapper header for <math.h> to ensure pi-related math constants are defined.
Describes a projection matrix fov.
Definition xrt_defines.h:533
A tightly packed 3x3 matrix of doubles.
Definition xrt_defines.h:590
A tightly packed 3x3 matrix of floats.
Definition xrt_defines.h:580
A tightly packed 4x4 matrix of floats.
Definition xrt_defines.h:607
A pose composed of a position and orientation.
Definition xrt_defines.h:513
A quaternion with single floats.
Definition xrt_defines.h:246
A 2 element vector with single floats.
Definition xrt_defines.h:279
A 3 element vector with single doubles.
Definition xrt_defines.h:322
A 3 element vector with single floats.
Definition xrt_defines.h:310
Common defines and enums for XRT.