The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/math: Add macros for degree/radian conversion

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2648>

+23 -20
+21
src/xrt/auxiliary/math/m_api.h
··· 18 18 19 19 #include "xrt/xrt_defines.h" 20 20 21 + #include "math/m_mathinclude.h" 22 + 21 23 #ifdef __cplusplus 22 24 extern "C" { 23 25 #endif ··· 74 76 * @ingroup aux_math 75 77 */ 76 78 #define CLAMP(X, A, B) (MIN(MAX((X), (A)), (B))) 79 + 80 + /*! 81 + * Degrees to radians conversion. 82 + * 83 + * @ingroup aux_math 84 + */ 85 + // clang-format off 86 + // @todo: Remove the clang-format off/on when we move to a newer clang-format in CI. 87 + #define DEG_TO_RAD(DEG) ((DEG) * M_PI / 180.) 88 + // clang-format on 89 + 90 + /*! 91 + * Radians to degrees conversion. 92 + * 93 + * @ingroup aux_math 94 + */ 95 + // clang-format off 96 + #define RAD_TO_DEG(RAD) ((RAD) * 180.0 / M_PI) 97 + // clang-format on 77 98 78 99 79 100 /*
-2
src/xrt/auxiliary/util/u_hand_simulation.c
··· 32 32 struct xrt_quat q[HAND_SIM_NUM_FINGERS][HAND_SIM_NUM_ORIENTATIONS_IN_FINGER]; 33 33 }; 34 34 35 - #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.) 36 - 37 35 // For debugging. 38 36 #if 0 39 37 #include <iostream>
-2
src/xrt/auxiliary/util/u_hand_tracking.c
··· 20 20 #include "util/u_time.h" 21 21 22 22 23 - #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.) 24 - 25 23 bool 26 24 u_hand_joint_is_metacarpal(enum xrt_hand_joint joint) 27 25 {
-2
src/xrt/auxiliary/vive/vive_poses.c
··· 12 12 #include "math/m_mathinclude.h" 13 13 #include "math/m_api.h" 14 14 15 - #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.) 16 - 17 15 static void 18 16 vive_poses_apply_right_transform(struct xrt_vec3 *out_transform_position, struct xrt_vec3 *out_transform_rotation) 19 17 {
-2
src/xrt/drivers/android/android_sensors.c
··· 133 133 args->tray_to_lens_distance_meters = params.tray_to_lens_distance; 134 134 } 135 135 136 - #define DEG_TO_RAD(x) (float)(x * M_PI / 180.0) 137 136 args->fov = (struct xrt_fov){.angle_left = -DEG_TO_RAD(angles[0]), 138 137 .angle_right = DEG_TO_RAD(angles[1]), 139 138 .angle_down = -DEG_TO_RAD(angles[2]), 140 139 .angle_up = DEG_TO_RAD(angles[3])}; 141 - #undef DEG_TO_RAD 142 140 143 141 ANDROID_INFO(d, "loaded calibration for device %s (%s)", model, vendor); 144 142
+2 -2
src/xrt/drivers/arduino/arduino_device.c
··· 405 405 406 406 m_imu_3dof_init(&ad->fusion, M_IMU_3DOF_USE_GRAVITY_DUR_300MS); 407 407 408 - #define DEG_TO_RAD ((double)M_PI / 180.0) 408 + #define DEG_TO_RAD_MULTIPLIER ((double)M_PI / 180.0) 409 409 float accel_ticks_to_float = (4.0 * MATH_GRAVITY_M_S2) / INT16_MAX; 410 - float gyro_ticks_to_float = (2000.0 * DEG_TO_RAD) / INT16_MAX; 410 + float gyro_ticks_to_float = (2000.0 * DEG_TO_RAD_MULTIPLIER) / INT16_MAX; 411 411 412 412 m_imu_pre_filter_init(&ad->pre_filter, accel_ticks_to_float, gyro_ticks_to_float); 413 413 m_imu_pre_filter_set_switch_x_and_y(&ad->pre_filter);
-2
src/xrt/drivers/pssense/pssense_driver.c
··· 43 43 44 44 DEBUG_GET_ONCE_LOG_OPTION(pssense_log, "PSSENSE_LOG", U_LOGGING_INFO) 45 45 46 - #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.) 47 - 48 46 static struct xrt_binding_input_pair simple_inputs_pssense[4] = { 49 47 {XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_PSSENSE_TRIGGER_VALUE}, 50 48 {XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_PSSENSE_OPTIONS_CLICK},
-1
src/xrt/drivers/rift/rift_interface.h
··· 37 37 #define IMU_SAMPLE_RATE (1000) // 1000hz 38 38 #define NS_PER_SAMPLE (1000 * 1000) // 1ms (1,000,000 ns) per sample 39 39 40 - #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.0) 41 40 #define MICROMETERS_TO_METERS(microns) (float)microns / 1000000.0f 42 41 43 42 // value taken from LibOVR 0.4.4
-2
src/xrt/drivers/rift_s/rift_s_controller.c
··· 40 40 /* Set to 1 to print controller states continuously */ 41 41 #define DUMP_CONTROLLER_STATE 0 42 42 43 - #define DEG_TO_RAD(D) ((D)*M_PI / 180.) 44 - 45 43 static struct xrt_binding_input_pair simple_inputs_rift_s[4] = { 46 44 {XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_TOUCH_TRIGGER_VALUE}, 47 45 {XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
-2
src/xrt/drivers/rift_s/rift_s_hmd.c
··· 40 40 41 41 #include "rift_s_hmd.h" 42 42 43 - #define DEG_TO_RAD(D) ((D)*M_PI / 180.) 44 - 45 43 46 44 static xrt_result_t 47 45 rift_s_get_tracked_pose(struct xrt_device *xdev,
-2
src/xrt/drivers/simula/svr_hmd.c
··· 97 97 return XRT_SUCCESS; 98 98 } 99 99 100 - #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.) 101 - 102 100 static xrt_result_t 103 101 svr_hmd_get_view_poses(struct xrt_device *xdev, 104 102 const struct xrt_vec3 *default_eye_relation,
-1
src/xrt/tracking/hand/mercury/hg_sync.cpp
··· 25 25 26 26 27 27 namespace xrt::tracking::hand::mercury { 28 - #define DEG_TO_RAD(DEG) (DEG * M_PI / 180.) 29 28 30 29 DEBUG_GET_ONCE_LOG_OPTION(mercury_log, "MERCURY_LOG", U_LOGGING_WARN) 31 30 DEBUG_GET_ONCE_BOOL_OPTION(mercury_optimize_hand_size, "MERCURY_optimize_hand_size", true)