31 struct xrt_vec3 ret = {l.x * r.x, l.y * r.y, l.z * r.z};
36m_vec3_mul_scalar(struct
xrt_vec3 l, float r)
38 struct xrt_vec3 ret = {l.x * r, l.y * r, l.z * r};
45 struct xrt_vec3 ret = {l.x + r.x, l.y + r.y, l.z + r.z};
52 struct xrt_vec3 ret = {l.x - r.x, l.y - r.y, l.z - r.z};
59 struct xrt_vec3 ret = {l.x / r.x, l.y / r.y, l.z / r.z};
64m_vec3_div_scalar(struct
xrt_vec3 l, float r)
66 struct xrt_vec3 ret = {l.x / r, l.y / r, l.z / r};
73 struct xrt_vec3 ret = {-v.x, -v.y, -v.z};
80 return l.x * r.x + l.y * r.y + l.z * r.z;
86 return m_vec3_dot(l, l);
92 return sqrtf(m_vec3_len_sqrd(l));
98 float len = m_vec3_len(l);
99 if (len <= FLT_EPSILON) {
114 float dot = m_vec3_dot(l, r);
115 float lengths = m_vec3_len_sqrd(l) * m_vec3_len_sqrd(r);
120 lengths = sqrtf(lengths);
122 return acosf(dot / lengths);
129 float amnt = (m_vec3_dot(project_this, onto_this) / m_vec3_len_sqrd(onto_this));
131 return m_vec3_mul_scalar(onto_this, amnt);
135m_vec3_orthonormalize(struct
xrt_vec3 leave_this_alone, struct
xrt_vec3 change_this_one)
137 return m_vec3_normalize(m_vec3_sub(change_this_one, m_vec3_project(change_this_one, leave_this_alone)));
144 return m_vec3_add(m_vec3_mul_scalar(from, 1.0f - amount), m_vec3_mul_scalar(to, amount));
150 return l.x == r.x && l.y == r.y && l.z == r.z;
153typedef float m_vec3_float_arr[3];
155static inline m_vec3_float_arr *
156m_vec3_ptr_to_float_arr_ptr(
struct xrt_vec3 *ptr)
158 return (m_vec3_float_arr *)ptr;
169 return m_vec3_add(a, b);
175 return m_vec3_sub(a, b);
179operator*(
const struct xrt_vec3 &a,
const float &b)
181 return m_vec3_mul_scalar(a, b);
187 return m_vec3_mul(a, b);
193 return m_vec3_div(a, b);
197operator/(const struct
xrt_vec3 &a,
const float &b)
199 return m_vec3_div_scalar(a, b);
221operator*=(
struct xrt_vec3 &a,
const float &b)
Wrapper header for <math.h> to ensure pi-related math constants are defined.
A 3 element vector with single floats.
Definition: xrt_defines.h:271
Common defines and enums for XRT.