adding ivec2, ivec3, ivec4 prints, eqv, eq and fill, documentation fixes

This commit is contained in:
duarm
2023-09-04 20:07:37 -03:00
parent f496146bce
commit 9d0c9fdb87
16 changed files with 380 additions and 5 deletions

View File

@@ -53,8 +53,11 @@ Functions:
1. :c:func:`glm_mat4_print`
#. :c:func:`glm_mat3_print`
#. :c:func:`glm_vec4_print`
#. :c:func:`glm_ivec4_print`
#. :c:func:`glm_vec3_print`
#. :c:func:`glm_ivec3_print`
#. :c:func:`glm_vec2_print`
#. :c:func:`glm_ivec2_print`
#. :c:func:`glm_versor_print`
#. :c:func:`glm_aabb_print`
@@ -63,7 +66,7 @@ Functions documentation
.. c:function:: void glm_mat4_print(mat4 matrix, FILE * __restrict ostream)
| print mat4 to given stream
| print matrix to given stream
Parameters:
| *[in]* **matrix** matrix
@@ -71,7 +74,7 @@ Functions documentation
.. c:function:: void glm_mat3_print(mat3 matrix, FILE * __restrict ostream)
| print mat3 to given stream
| print matrix to given stream
Parameters:
| *[in]* **matrix** matrix
@@ -79,7 +82,15 @@ Functions documentation
.. c:function:: void glm_vec4_print(vec4 vec, FILE * __restrict ostream)
| print vec4 to given stream
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_ivec4_print(ivec4 vec, FILE * __restrict ostream)
| print vector to given stream
Parameters:
| *[in]* **vec** vector
@@ -87,7 +98,7 @@ Functions documentation
.. c:function:: void glm_vec3_print(vec3 vec, FILE * __restrict ostream)
| print vec3 to given stream
| print vector to given stream
Parameters:
| *[in]* **vec** vector
@@ -95,12 +106,29 @@ Functions documentation
.. c:function:: void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream)
| print ivec3 to given stream
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_vec2_print(vec2 vec, FILE * __restrict ostream)
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_ivec2_print(ivec2 vec, FILE * __restrict ostream)
| print vector to given stream
Parameters:
| *[in]* **vec** vector
| *[in]* **ostream** FILE to write
.. c:function:: void glm_versor_print(versor vec, FILE * __restrict ostream)
| print quaternion to given stream

View File

@@ -143,6 +143,31 @@ Functions documentation
Returns:
distance
.. c:function:: void glm_ivec2_fill(ivec2 v, float val)
fill a vector with specified value
Parameters:
| *[out]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec2_eq(ivec2 v, float val)
check if vector is equal to value
Parameters:
| *[in]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec2_eqv(ivec2 v1, ivec2 v2)
check if vector is equal to another vector
Parameters:
| *[in]* **vec** vector 1
| *[in]* **vec** vector 2
.. c:function:: void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest)
set each member of dest to greater of vector a and b

View File

@@ -29,6 +29,9 @@ Functions:
#. :c:func:`glm_ivec3_scale`
#. :c:func:`glm_ivec3_distance2`
#. :c:func:`glm_ivec3_distance`
#. :c:func:`glm_ivec3_fill`
#. :c:func:`glm_ivec3_eq`
#. :c:func:`glm_ivec3_eqv`
#. :c:func:`glm_ivec3_maxv`
#. :c:func:`glm_ivec3_minv`
#. :c:func:`glm_ivec3_clamp`
@@ -143,6 +146,30 @@ Functions documentation
Returns:
distance
.. c:function:: void glm_ivec3_fill(ivec3 v, float val)
fill a vector with specified value
Parameters:
| *[out]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec3_eq(ivec3 v, float val)
check if vector is equal to value
Parameters:
| *[in]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_ivec3_eqv(ivec3 v1, ivec3 v2)
check if vector is equal to another vector
Parameters:
| *[in]* **vec** vector 1
| *[in]* **vec** vector 2
.. c:function:: void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest)
set each member of dest to greater of vector a and b

View File

@@ -50,6 +50,14 @@ Functions documentation
| *[in]* **val** value
| *[out]* **dest** destination
.. c:function:: void glm_vec3_fill(vec3 v, float val)
fill a vector with specified value
Parameters:
| *[out]* **v** vector
| *[in]* **val** value
.. c:function:: bool glm_vec3_eq(vec3 v, float val)
check if vector is equal to value (without epsilon)

View File

@@ -61,6 +61,18 @@ CGLM_EXPORT
float
glmc_ivec2_distance(ivec2 a, ivec2 b);
CGLM_EXPORT
void
glmc_ivec2_fill(ivec2 v, float val);
CGLM_EXPORT
bool
glmc_ivec2_eq(ivec2 v, float val);
CGLM_EXPORT
bool
glmc_ivec2_eqv(ivec2 a, ivec2 b);
CGLM_EXPORT
void
glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest);

View File

@@ -61,6 +61,18 @@ CGLM_EXPORT
float
glmc_ivec3_distance(ivec3 a, ivec3 b);
CGLM_EXPORT
void
glmc_ivec3_fill(ivec3 v, float val);
CGLM_EXPORT
bool
glmc_ivec3_eq(ivec3 v, float val);
CGLM_EXPORT
bool
glmc_ivec3_eqv(ivec3 a, ivec3 b);
CGLM_EXPORT
void
glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest);

View File

@@ -10,8 +10,11 @@
CGLM_INLINE void glm_mat4_print(mat4 matrix, FILE *ostream);
CGLM_INLINE void glm_mat3_print(mat3 matrix, FILE *ostream);
CGLM_INLINE void glm_vec4_print(vec4 vec, FILE *ostream);
CGLM_INLINE void glm_ivec4_print(ivec4 vec, FILE *ostream);
CGLM_INLINE void glm_vec3_print(vec3 vec, FILE *ostream);
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
CGLM_INLINE void glm_vec2_print(vec2 vec, FILE *ostream);
CGLM_INLINE void glm_ivec2_print(ivec2 vec, FILE *ostream);
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
CGLM_INLINE void glm_arch_print(FILE *ostream);
*/
@@ -261,6 +264,24 @@ glm_vec4_print(vec4 vec,
#undef m
}
CGLM_INLINE
void
glm_ivec4_print(ivec4 vec,
FILE * __restrict ostream) {
int i;
#define m 4
fprintf(ostream, "Vector (int%d): " CGLM_PRINT_COLOR "\n (", m);
for (i = 0; i < m; i++)
fprintf(ostream, " % d", vec[i]);
fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n");
#undef m
}
CGLM_INLINE
void
glm_vec3_print(vec3 vec,
@@ -323,6 +344,24 @@ glm_vec2_print(vec2 vec,
#undef m
}
CGLM_INLINE
void
glm_ivec2_print(ivec2 vec,
FILE * __restrict ostream) {
int i;
#define m 2
fprintf(ostream, "Vector (int%d): " CGLM_PRINT_COLOR "\n (", m);
for (i = 0; i < m; i++)
fprintf(ostream, " % d", vec[i]);
fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n");
#undef m
}
CGLM_INLINE
void
glm_versor_print(versor vec,
@@ -387,9 +426,11 @@ glm_aabb_print(vec3 bbox[2],
#define glm_mat3_print(v, s) (void)v; (void)s;
#define glm_mat2_print(v, s) (void)v; (void)s;
#define glm_vec4_print(v, s) (void)v; (void)s;
#define glm_ivec4_print(v, s) (void)v; (void)s;
#define glm_vec3_print(v, s) (void)v; (void)s;
#define glm_ivec3_print(v, s) (void)v; (void)s;
#define glm_vec2_print(v, s) (void)v; (void)s;
#define glm_ivec2_print(v, s) (void)v; (void)s;
#define glm_versor_print(v, s) (void)v; (void)s;
#define glm_aabb_print(v, t, s) (void)v; (void)t; (void)s;
#define glm_arch_print(s) (void)s;

View File

@@ -25,6 +25,9 @@
CGLM_INLINE void glm_ivec2_scale(ivec2 v, int s, ivec2 dest)
CGLM_INLINE int glm_ivec2_distance2(ivec2 a, ivec2 b)
CGLM_INLINE float glm_ivec2_distance(ivec2 a, ivec2 b)
CGLM_INLINE void glm_ivec2_fill(ivec2 v, float val);
CGLM_INLINE bool glm_ivec2_eq(ivec2 v, float val);
CGLM_INLINE bool glm_ivec2_eqv(ivec2 a, ivec2 b);
CGLM_INLINE void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest)
CGLM_INLINE void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest)
CGLM_INLINE void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal)
@@ -203,6 +206,44 @@ glm_ivec2_distance(ivec2 a, ivec2 b) {
return sqrtf((float)glm_ivec2_distance2(a, b));
}
/*!
* @brief fill a vector with specified value
*
* @param[out] v dest
* @param[in] val value
*/
CGLM_INLINE
void
glm_ivec2_fill(ivec2 v, float val) {
v[0] = v[1] = val;
}
/*!
* @brief check if vector is equal to value
*
* @param[in] v vector
* @param[in] val value
*/
CGLM_INLINE
bool
glm_ivec2_eq(ivec2 v, float val) {
return v[0] == val && v[0] == v[1];
}
/*!
* @brief check if vector is equal to another
*
* @param[in] a vector
* @param[in] b vector
*/
CGLM_INLINE
bool
glm_ivec2_eqv(ivec2 a, ivec2 b) {
return a[0] == b[0]
&& a[1] == b[1];
}
/*!
* @brief set each member of dest to greater of vector a and b
*

View File

@@ -25,6 +25,9 @@
CGLM_INLINE void glm_ivec3_scale(ivec3 v, int s, ivec3 dest)
CGLM_INLINE int glm_ivec3_distance2(ivec3 a, ivec3 b)
CGLM_INLINE float glm_ivec3_distance(ivec3 a, ivec3 b)
CGLM_INLINE void glm_ivec3_fill(ivec3 v, float val);
CGLM_INLINE bool glm_ivec3_eq(ivec3 v, float val);
CGLM_INLINE bool glm_ivec3_eqv(ivec3 a, ivec3 b);
CGLM_INLINE void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest)
CGLM_INLINE void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest)
CGLM_INLINE void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal)
@@ -212,6 +215,44 @@ glm_ivec3_distance(ivec3 a, ivec3 b) {
return sqrtf((float)glm_ivec3_distance2(a, b));
}
/*!
* @brief fill a vector with specified value
*
* @param[out] v dest
* @param[in] val value
*/
CGLM_INLINE
void
glm_ivec3_fill(ivec3 v, float val) {
v[0] = v[1] = v[2] = val;
}
/*!
* @brief check if vector is equal to value
*
* @param[in] v vector
* @param[in] val value
*/
CGLM_INLINE
bool
glm_ivec3_eq(ivec3 v, float val) {
return v[0] == val && v[0] == v[1] && v[0] == v[2];
}
/*!
* @brief check if vector is equal to another
*
* @param[in] a vector
* @param[in] b vector
*/
CGLM_INLINE
bool
glm_ivec3_eqv(ivec3 a, ivec3 b) {
return a[0] == b[0]
&& a[1] == b[1]
&& a[2] == b[2];
}
/*!
* @brief set each member of dest to greater of vector a and b
*

View File

@@ -12,6 +12,8 @@
CGLM_INLINE void glm_vec4_print(vec4 vec, FILE *ostream);
CGLM_INLINE void glm_vec3_print(vec3 vec, FILE *ostream);
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
CGLM_INLINE void glm_ivec3_print(ivec3 vec, FILE *ostream);
CGLM_INLINE void glm_versor_print(versor vec, FILE *ostream);
*/

View File

@@ -80,6 +80,24 @@ glmc_ivec2_distance(ivec2 a, ivec2 b) {
return glm_ivec2_distance(a, b);
}
CGLM_EXPORT
void
glmc_ivec2_fill(ivec2 v, float val) {
glm_ivec2_fill(v, val);
}
CGLM_EXPORT
bool
glmc_ivec2_eq(ivec2 v, float val) {
return glm_ivec2_eq(v, val);
}
CGLM_EXPORT
bool
glmc_ivec2_eqv(ivec2 a, ivec2 b) {
return glm_ivec2_eqv(a, b);
}
CGLM_EXPORT
void
glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) {

View File

@@ -80,6 +80,24 @@ glmc_ivec3_distance(ivec3 a, ivec3 b) {
return glm_ivec3_distance(a, b);
}
CGLM_EXPORT
void
glmc_ivec3_fill(ivec3 v, float val) {
glm_ivec3_fill(v, val);
}
CGLM_EXPORT
bool
glmc_ivec3_eq(ivec3 v, float val) {
return glm_ivec3_eq(v, val);
}
CGLM_EXPORT
bool
glmc_ivec3_eqv(ivec3 a, ivec3 b) {
return glm_ivec3_eqv(a, b);
}
CGLM_EXPORT
void
glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) {

View File

@@ -14,6 +14,12 @@ glmc_vec2(float * __restrict v, vec2 dest) {
glm_vec2(v, dest);
}
CGLM_EXPORT
void
glmc_vec2_fill(vec2 v, float val) {
glm_vec2_fill(v, val);
}
CGLM_EXPORT
void
glmc_vec2_copy(vec2 a, vec2 dest) {

View File

@@ -148,6 +148,42 @@ TEST_IMPL(GLM_PREFIX, ivec2_distance) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec2_fill) {
ivec2 v1;
ivec2 v2 = {-1, 3};
GLM(ivec2_fill)(v1, 1);
GLM(ivec2_fill)(v2, 2);
ASSERT(GLM(ivec2_eq)(v1, 1))
ASSERT(GLM(ivec2_eq)(v2, 2))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec2_eq) {
ivec2 v1 = {-1, 2};
GLM(ivec2_fill)(v1, 2);
ASSERT(GLM(ivec2_eq)(v1, 2))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec2_eqv) {
ivec2 v1, v2, v3;
GLM(ivec2_fill)(v1, 1);
GLM(ivec2_fill)(v2, 2);
GLM(ivec2_fill)(v3, 1);
ASSERT(GLM(ivec2_eqv)(v1, v3))
ASSERT(!GLM(ivec2_eqv)(v1, v2))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec2_maxv) {
ivec2 a = {9, -20};
ivec2 b = {8, -1};

View File

@@ -153,6 +153,42 @@ TEST_IMPL(GLM_PREFIX, ivec3_distance) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec3_fill) {
ivec3 v1;
ivec3 v2 = {-1, 3, 4};
GLM(ivec3_fill)(v1, 1);
GLM(ivec3_fill)(v2, 2);
ASSERT(GLM(ivec3_eq)(v1, 1))
ASSERT(GLM(ivec3_eq)(v2, 2))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec3_eq) {
ivec3 v1 = { -1, 2, 4 };
GLM(ivec3_fill)(v1, 2);
ASSERT(GLM(ivec3_eq)(v1, 2))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec3_eqv) {
ivec3 v1, v2, v3;
GLM(ivec3_fill)(v1, 1);
GLM(ivec3_fill)(v2, 2);
GLM(ivec3_fill)(v3, 1);
ASSERT(GLM(ivec3_eqv)(v1, v3))
ASSERT(!GLM(ivec3_eqv)(v1, v2))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec3_maxv) {
ivec3 a = {9, -20, 5};
ivec3 b = {8, -1, 2};

View File

@@ -862,6 +862,9 @@ TEST_DECLARE(glm_ivec2_mul)
TEST_DECLARE(glm_ivec2_scale)
TEST_DECLARE(glm_ivec2_distance2)
TEST_DECLARE(glm_ivec2_distance)
TEST_DECLARE(glm_ivec2_fill)
TEST_DECLARE(glm_ivec2_eq)
TEST_DECLARE(glm_ivec2_eqv)
TEST_DECLARE(glm_ivec2_maxv)
TEST_DECLARE(glm_ivec2_minv)
TEST_DECLARE(glm_ivec2_clamp)
@@ -879,6 +882,9 @@ TEST_DECLARE(glmc_ivec2_mul)
TEST_DECLARE(glmc_ivec2_scale)
TEST_DECLARE(glmc_ivec2_distance2)
TEST_DECLARE(glmc_ivec2_distance)
TEST_DECLARE(glmc_ivec2_fill)
TEST_DECLARE(glmc_ivec2_eq)
TEST_DECLARE(glmc_ivec2_eqv)
TEST_DECLARE(glmc_ivec2_maxv)
TEST_DECLARE(glmc_ivec2_minv)
TEST_DECLARE(glmc_ivec2_clamp)
@@ -897,6 +903,9 @@ TEST_DECLARE(glm_ivec3_mul)
TEST_DECLARE(glm_ivec3_scale)
TEST_DECLARE(glm_ivec3_distance2)
TEST_DECLARE(glm_ivec3_distance)
TEST_DECLARE(glm_ivec3_fill)
TEST_DECLARE(glm_ivec3_eq)
TEST_DECLARE(glm_ivec3_eqv)
TEST_DECLARE(glm_ivec3_maxv)
TEST_DECLARE(glm_ivec3_minv)
TEST_DECLARE(glm_ivec3_clamp)
@@ -913,6 +922,9 @@ TEST_DECLARE(glmc_ivec3_mul)
TEST_DECLARE(glmc_ivec3_scale)
TEST_DECLARE(glmc_ivec3_distance2)
TEST_DECLARE(glmc_ivec3_distance)
TEST_DECLARE(glmc_ivec3_fill)
TEST_DECLARE(glmc_ivec3_eq)
TEST_DECLARE(glmc_ivec3_eqv)
TEST_DECLARE(glmc_ivec3_maxv)
TEST_DECLARE(glmc_ivec3_minv)
TEST_DECLARE(glmc_ivec3_clamp)
@@ -1823,6 +1835,9 @@ TEST_LIST {
TEST_ENTRY(glm_ivec2_scale)
TEST_ENTRY(glm_ivec2_distance2)
TEST_ENTRY(glm_ivec2_distance)
TEST_ENTRY(glm_ivec2_fill)
TEST_ENTRY(glm_ivec2_eq)
TEST_ENTRY(glm_ivec2_eqv)
TEST_ENTRY(glm_ivec2_maxv)
TEST_ENTRY(glm_ivec2_minv)
TEST_ENTRY(glm_ivec2_clamp)
@@ -1840,6 +1855,9 @@ TEST_LIST {
TEST_ENTRY(glmc_ivec2_scale)
TEST_ENTRY(glmc_ivec2_distance2)
TEST_ENTRY(glmc_ivec2_distance)
TEST_ENTRY(glmc_ivec2_fill)
TEST_ENTRY(glmc_ivec2_eq)
TEST_ENTRY(glmc_ivec2_eqv)
TEST_ENTRY(glmc_ivec2_maxv)
TEST_ENTRY(glmc_ivec2_minv)
TEST_ENTRY(glmc_ivec2_clamp)
@@ -1858,6 +1876,9 @@ TEST_LIST {
TEST_ENTRY(glm_ivec3_scale)
TEST_ENTRY(glm_ivec3_distance2)
TEST_ENTRY(glm_ivec3_distance)
TEST_ENTRY(glm_ivec3_fill)
TEST_ENTRY(glm_ivec3_eq)
TEST_ENTRY(glm_ivec3_eqv)
TEST_ENTRY(glm_ivec3_maxv)
TEST_ENTRY(glm_ivec3_minv)
TEST_ENTRY(glm_ivec3_clamp)
@@ -1874,6 +1895,9 @@ TEST_LIST {
TEST_ENTRY(glmc_ivec3_scale)
TEST_ENTRY(glmc_ivec3_distance2)
TEST_ENTRY(glmc_ivec3_distance)
TEST_ENTRY(glmc_ivec3_fill)
TEST_ENTRY(glmc_ivec3_eq)
TEST_ENTRY(glmc_ivec3_eqv)
TEST_ENTRY(glmc_ivec3_maxv)
TEST_ENTRY(glmc_ivec3_minv)
TEST_ENTRY(glmc_ivec3_clamp)