Merge branch 'vec2_mat2' of https://github.com/recp/cglm into vec2_mat2

This commit is contained in:
Recep Aslantas
2019-09-01 17:12:12 +03:00
14 changed files with 552 additions and 0 deletions

View File

@@ -24,6 +24,9 @@
CGLM_INLINE bool glms_vec3_isinf(vec3s v);
CGLM_INLINE bool glms_vec3_isvalid(vec3s v);
CGLM_INLINE vec3s glms_vec3_sign(vec3s v);
CGLM_INLINE vec3s glms_vec3_abs(vec3s v);
CGLM_INLINE vec3s glms_vec3_fract(vec3s v);
CGLM_INLINE float glms_vec3_hadd(vec3s v);
CGLM_INLINE vec3s glms_vec3_sqrt(vec3s v);
*/
@@ -196,6 +199,47 @@ glms_vec3_sign(vec3s v) {
return r;
}
/*!
* @brief absolute value of each vector item
*
* @param[in] v vector
* @return destination vector
*/
CGLM_INLINE
vec3s
glms_vec3_abs(vec3s v) {
vec3s r;
glm_vec3_abs(v.raw, r.raw);
return r;
}
/*!
* @brief fractional part of each vector item
*
* @param[in] v vector
* @return dest destination vector
*/
CGLM_INLINE
vec3s
glms_vec3_fract(vec3s v) {
vec3s r;
glm_vec3_fract(v.raw, r.raw);
return r;
}
/*!
* @brief vector reduction by summation
* @warning could overflow
*
* @param[in] v vector
* @return sum of all vector's elements
*/
CGLM_INLINE
float
glms_vec3_hadd(vec3s v) {
return glm_vec3_hadd(v.raw);
}
/*!
* @brief square root of each vector item
*

View File

@@ -24,6 +24,8 @@
CGLM_INLINE float glms_vec3_dot(vec3s a, vec3s b);
CGLM_INLINE float glms_vec3_norm2(vec3s v);
CGLM_INLINE float glms_vec3_norm(vec3s v);
CGLM_INLINE float glms_vec3_norm_one(vec3s v);
CGLM_INLINE float glms_vec3_norm_inf(vec3s v);
CGLM_INLINE vec3s glms_vec3_add(vec3s a, vec3s b);
CGLM_INLINE vec3s glms_vec3_adds(vec3s a, float s);
CGLM_INLINE vec3s glms_vec3_sub(vec3s a, vec3s b);
@@ -212,6 +214,45 @@ glms_vec3_norm(vec3s v) {
return glm_vec3_norm(v.raw);
}
/*!
* @brief L1 norm of vec3
* Also known as Manhattan Distance or Taxicab norm.
* L1 Norm is the sum of the magnitudes of the vectors in a space.
* It is calculated as the sum of the absolute values of the vector components.
* In this norm, all the components of the vector are weighted equally.
*
* This computes:
* R = |v[0]| + |v[1]| + |v[2]|
*
* @param[in] v vector
*
* @return L1 norm
*/
CGLM_INLINE
float
glms_vec3_norm_one(vec3s v) {
return glm_vec3_norm_one(v.raw);
}
/*!
* @brief Infinity norm of vec3
* Also known as Maximum norm.
* Infinity Norm is the largest magnitude among each element of a vector.
* It is calculated as the maximum of the absolute values of the vector components.
*
* This computes:
* inf norm = max(|v[0]|, |v[1]|, |v[2]|)
*
* @param[in] v vector
*
* @return Infinity norm
*/
CGLM_INLINE
float
glms_vec3_norm_inf(vec3s v) {
return glm_vec3_norm_inf(v.raw);
}
/*!
* @brief add a vector to b vector store result in dest
*

View File

@@ -24,6 +24,9 @@
CGLM_INLINE bool glms_vec4_isinf(vec4s v);
CGLM_INLINE bool glms_vec4_isvalid(vec4s v);
CGLM_INLINE vec4s glms_vec4_sign(vec4s v);
CGLM_INLINE vec4s glms_vec4_abs(vec4s v);
CGLM_INLINE vec4s glms_vec4_fract(vec4s v);
CGLM_INLINE float glms_vec4_hadd(vec4s v);
CGLM_INLINE vec4s glms_vec4_sqrt(vec4s v);
*/
@@ -196,6 +199,47 @@ glms_vec4_sign(vec4s v) {
return r;
}
/*!
* @brief absolute value of each vector item
*
* @param[in] v vector
* @returns destination vector
*/
CGLM_INLINE
vec4s
glms_vec4_abs(vec4s v) {
vec4s r;
glm_vec4_abs(v.raw, r.raw);
return r;
}
/*!
* @brief fractional part of each vector item
*
* @param[in] v vector
* @returns dest destination vector
*/
CGLM_INLINE
vec4s
glms_vec4_fract(vec4s v) {
vec4s r;
glm_vec4_fract(v.raw, r.raw);
return r;
}
/*!
* @brief vector reduction by summation
* @warning could overflow
*
* @param[in] v vector
* @return sum of all vector's elements
*/
CGLM_INLINE
float
glms_vec4_hadd(vec4s v) {
return glm_vec4_hadd(v.raw);
}
/*!
* @brief square root of each vector item
*

View File

@@ -24,6 +24,8 @@
CGLM_INLINE float glms_vec4_dot(vec4s a, vec4s b);
CGLM_INLINE float glms_vec4_norm2(vec4s v);
CGLM_INLINE float glms_vec4_norm(vec4s v);
CGLM_INLINE float glms_vec4_norm_one(vec4s v);
CGLM_INLINE float glms_vec4_norm_inf(vec4s v);
CGLM_INLINE vec4s glms_vec4_add(vec4s a, vec4s b);
CGLM_INLINE vec4s glms_vec4_adds(vec4s v, float s);
CGLM_INLINE vec4s glms_vec4_sub(vec4s a, vec4s b);
@@ -241,6 +243,45 @@ glms_vec4_norm(vec4s v) {
return glm_vec4_norm(v.raw);
}
/*!
* @brief L1 norm of vec4
* Also known as Manhattan Distance or Taxicab norm.
* L1 Norm is the sum of the magnitudes of the vectors in a space.
* It is calculated as the sum of the absolute values of the vector components.
* In this norm, all the components of the vector are weighted equally.
*
* This computes:
* R = |v[0]| + |v[1]| + |v[2]| + |v[3]|
*
* @param[in] v vector
*
* @return L1 norm
*/
CGLM_INLINE
float
glms_vec4_norm_one(vec4s v) {
return glm_vec4_norm_one(v.raw);
}
/*!
* @brief Infinity norm of vec4
* Also known as Maximum norm.
* Infinity Norm is the largest magnitude among each element of a vector.
* It is calculated as the maximum of the absolute values of the vector components.
*
* This computes:
* inf norm = max(|v[0]|, |v[1]|, |v[2]|, |v[3]|)
*
* @param[in] v vector
*
* @return Infinity norm
*/
CGLM_INLINE
float
glms_vec4_norm_inf(vec4s v) {
return glm_vec4_norm_inf(v.raw);
}
/*!
* @brief add b vector to a vector store result in dest
*