The open source OpenXR runtime
0
fork

Configure Feed

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

math: Added vec3 math functions

authored by

Nova and committed by
Jakob Bornecrantz
4cfd4c46 f3803f73

+79
+1
src/xrt/auxiliary/CMakeLists.txt
··· 9 9 math/m_optics.c 10 10 math/m_quatexpmap.cpp 11 11 math/m_vec2.h 12 + math/m_vec3.h 12 13 ) 13 14 14 15 set(OGL_SOURCE_FILES
+77
src/xrt/auxiliary/math/m_vec3.h
··· 1 + // Copyright 2019-2020, Collabora, Ltd. 2 + // Copyright 2020, Nova King. 3 + // SPDX-License-Identifier: BSL-1.0 4 + /*! 5 + * @file 6 + * @brief C vec3 math library. 7 + * @author Jakob Bornecrantz <jakob@collabora.com> 8 + * @author Nova King <technobaboo@gmail.com> 9 + * 10 + * @see xrt_vec3 11 + * @ingroup aux_math 12 + */ 13 + 14 + #pragma once 15 + 16 + #include "xrt/xrt_defines.h" 17 + 18 + #include <math.h> 19 + 20 + 21 + #ifdef __cplusplus 22 + extern "C" { 23 + #endif 24 + 25 + 26 + static inline struct xrt_vec3 27 + m_vec3_mul(struct xrt_vec3 l, struct xrt_vec3 r) 28 + { 29 + struct xrt_vec3 ret = {l.x * r.x, l.y * r.y, l.z * r.z}; 30 + return ret; 31 + } 32 + 33 + static inline struct xrt_vec3 34 + m_vec3_mul_scalar(struct xrt_vec3 l, float r) 35 + { 36 + struct xrt_vec3 ret = {l.x * r, l.y * r, l.z * r}; 37 + return ret; 38 + } 39 + 40 + static inline struct xrt_vec3 41 + m_vec3_add(struct xrt_vec3 l, struct xrt_vec3 r) 42 + { 43 + struct xrt_vec3 ret = {l.x + r.x, l.y + r.y, l.z + r.z}; 44 + return ret; 45 + } 46 + 47 + static inline struct xrt_vec3 48 + m_vec3_sub(struct xrt_vec3 l, struct xrt_vec3 r) 49 + { 50 + struct xrt_vec3 ret = {l.x - r.x, l.y - r.y, l.z - r.z}; 51 + return ret; 52 + } 53 + 54 + static inline struct xrt_vec3 55 + m_vec3_div(struct xrt_vec3 l, struct xrt_vec3 r) 56 + { 57 + struct xrt_vec3 ret = {l.x / r.x, l.y / r.y, l.z / r.z}; 58 + return ret; 59 + } 60 + 61 + static inline struct xrt_vec3 62 + m_vec3_div_scalar(struct xrt_vec3 l, float r) 63 + { 64 + struct xrt_vec3 ret = {l.x / r, l.y / r, l.z / r}; 65 + return ret; 66 + } 67 + 68 + static inline float 69 + m_vec3_len(struct xrt_vec3 l) 70 + { 71 + return sqrtf(l.x * l.x + l.y * l.y + l.z * l.z); 72 + } 73 + 74 + 75 + #ifdef __cplusplus 76 + } 77 + #endif
+1
src/xrt/auxiliary/meson.build
··· 92 92 'math/m_optics.c', 93 93 'math/m_quatexpmap.cpp', 94 94 'math/m_vec2.h', 95 + 'math/m_vec3.h', 95 96 ), 96 97 include_directories: xrt_include, 97 98 dependencies: [eigen3],