Skip to content

Commit

Permalink
adding ivec2, ivec3, ivec4 prints, eqv, eq and fill, documentation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
duarm committed Sep 4, 2023
1 parent f496146 commit 9d0c9fd
Show file tree
Hide file tree
Showing 16 changed files with 380 additions and 5 deletions.
38 changes: 33 additions & 5 deletions docs/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -63,44 +66,69 @@ 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
| *[in]* **ostream** FILE to write
.. 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
| *[in]* **ostream** FILE to write
.. 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
| *[in]* **ostream** FILE to write
.. 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
| *[in]* **ostream** FILE to write
.. 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
Expand Down
25 changes: 25 additions & 0 deletions docs/source/ivec2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions docs/source/ivec3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions docs/source/vec3-ext.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions include/cglm/call/ivec2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions include/cglm/call/ivec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 41 additions & 0 deletions include/cglm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
*/
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
41 changes: 41 additions & 0 deletions include/cglm/ivec2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
*
Expand Down
41 changes: 41 additions & 0 deletions include/cglm/ivec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
*
Expand Down
Loading

0 comments on commit 9d0c9fd

Please sign in to comment.