vec: rename glm_vec_ to glm_vec3_ (continue)

* add missing functions to vec4
* update docs
This commit is contained in:
Recep Aslantas
2018-11-29 09:07:48 +03:00
parent 0b8c63a90e
commit b4bf8f3537
18 changed files with 214 additions and 221 deletions

View File

@@ -5,9 +5,14 @@ vec3
Header: cglm/vec3.h
**Important:** *cglm* was used **glm_vec_** namespace for vec3 functions until
**v0.5.0**, since **v0.5.0** cglm uses **glm_vec3_** namespace for vec3.
Also `glm_vec3_flipsign` has been renamed to `glm_vec3_negate`
We mostly use vectors in graphics math, to make writing code faster
and easy to read, some *vec3* functions are aliased in global namespace.
For instance :c:func:`glm_dot` is alias of :c:func:`glm_vec_dot`,
For instance :c:func:`glm_dot` is alias of :c:func:`glm_vec3_dot`,
alias means inline wrapper here. There is no call verison of alias functions
There are also functions for rotating *vec3* vector. **_m4**, **_m3** prefixes
@@ -18,7 +23,7 @@ Table of contents (click to go):
Macros:
1. glm_vec_dup(v, dest)
1. glm_vec3_dup(v, dest)
#. GLM_VEC3_ONE_INIT
#. GLM_VEC3_ZERO_INIT
#. GLM_VEC3_ONE
@@ -30,47 +35,47 @@ Macros:
Functions:
1. :c:func:`glm_vec3`
#. :c:func:`glm_vec_copy`
#. :c:func:`glm_vec_zero`
#. :c:func:`glm_vec_one`
#. :c:func:`glm_vec_dot`
#. :c:func:`glm_vec_cross`
#. :c:func:`glm_vec_norm2`
#. :c:func:`glm_vec_norm`
#. :c:func:`glm_vec_add`
#. :c:func:`glm_vec_adds`
#. :c:func:`glm_vec_sub`
#. :c:func:`glm_vec_subs`
#. :c:func:`glm_vec_mul`
#. :c:func:`glm_vec_scale`
#. :c:func:`glm_vec_scale_as`
#. :c:func:`glm_vec_div`
#. :c:func:`glm_vec_divs`
#. :c:func:`glm_vec_addadd`
#. :c:func:`glm_vec_subadd`
#. :c:func:`glm_vec_muladd`
#. :c:func:`glm_vec_muladds`
#. :c:func:`glm_vec_flipsign`
#. :c:func:`glm_vec_flipsign_to`
#. :c:func:`glm_vec_negate`
#. :c:func:`glm_vec_negate_to`
#. :c:func:`glm_vec_inv`
#. :c:func:`glm_vec_inv_to`
#. :c:func:`glm_vec_normalize`
#. :c:func:`glm_vec_normalize_to`
#. :c:func:`glm_vec_distance2`
#. :c:func:`glm_vec_distance`
#. :c:func:`glm_vec_angle`
#. :c:func:`glm_vec_rotate`
#. :c:func:`glm_vec_rotate_m4`
#. :c:func:`glm_vec_rotate_m3`
#. :c:func:`glm_vec_proj`
#. :c:func:`glm_vec_center`
#. :c:func:`glm_vec_maxv`
#. :c:func:`glm_vec_minv`
#. :c:func:`glm_vec_ortho`
#. :c:func:`glm_vec_clamp`
#. :c:func:`glm_vec_lerp`
#. :c:func:`glm_vec3_copy`
#. :c:func:`glm_vec3_zero`
#. :c:func:`glm_vec3_one`
#. :c:func:`glm_vec3_dot`
#. :c:func:`glm_vec3_cross`
#. :c:func:`glm_vec3_norm2`
#. :c:func:`glm_vec3_norm`
#. :c:func:`glm_vec3_add`
#. :c:func:`glm_vec3_adds`
#. :c:func:`glm_vec3_sub`
#. :c:func:`glm_vec3_subs`
#. :c:func:`glm_vec3_mul`
#. :c:func:`glm_vec3_scale`
#. :c:func:`glm_vec3_scale_as`
#. :c:func:`glm_vec3_div`
#. :c:func:`glm_vec3_divs`
#. :c:func:`glm_vec3_addadd`
#. :c:func:`glm_vec3_subadd`
#. :c:func:`glm_vec3_muladd`
#. :c:func:`glm_vec3_muladds`
#. :c:func:`glm_vec3_flipsign`
#. :c:func:`glm_vec3_flipsign_to`
#. :c:func:`glm_vec3_negate`
#. :c:func:`glm_vec3_negate_to`
#. :c:func:`glm_vec3_inv`
#. :c:func:`glm_vec3_inv_to`
#. :c:func:`glm_vec3_normalize`
#. :c:func:`glm_vec3_normalize_to`
#. :c:func:`glm_vec3_distance2`
#. :c:func:`glm_vec3_distance`
#. :c:func:`glm_vec3_angle`
#. :c:func:`glm_vec3_rotate`
#. :c:func:`glm_vec3_rotate_m4`
#. :c:func:`glm_vec3_rotate_m3`
#. :c:func:`glm_vec3_proj`
#. :c:func:`glm_vec3_center`
#. :c:func:`glm_vec3_maxv`
#. :c:func:`glm_vec3_minv`
#. :c:func:`glm_vec3_ortho`
#. :c:func:`glm_vec3_clamp`
#. :c:func:`glm_vec3_lerp`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -83,7 +88,7 @@ Functions documentation
| *[in]* **v4** vector4
| *[out]* **dest** destination
.. c:function:: void glm_vec_copy(vec3 a, vec3 dest)
.. c:function:: void glm_vec3_copy(vec3 a, vec3 dest)
copy all members of [a] to [dest]
@@ -91,21 +96,21 @@ Functions documentation
| *[in]* **a** source
| *[out]* **dest** destination
.. c:function:: void glm_vec_zero(vec3 v)
.. c:function:: void glm_vec3_zero(vec3 v)
makes all members 0.0f (zero)
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec_one(vec3 v)
.. c:function:: void glm_vec3_one(vec3 v)
makes all members 1.0f (one)
Parameters:
| *[in, out]* **v** vector
.. c:function:: float glm_vec_dot(vec3 a, vec3 b)
.. c:function:: float glm_vec3_dot(vec3 a, vec3 b)
dot product of vec3
@@ -116,7 +121,7 @@ Functions documentation
Returns:
dot product
.. c:function:: void glm_vec_cross(vec3 a, vec3 b, vec3 d)
.. c:function:: void glm_vec3_cross(vec3 a, vec3 b, vec3 d)
cross product
@@ -125,7 +130,7 @@ Functions documentation
| *[in]* **b** source 2
| *[out]* **d** destination
.. c:function:: float glm_vec_norm2(vec3 v)
.. c:function:: float glm_vec3_norm2(vec3 v)
norm * norm (magnitude) of vector
@@ -139,14 +144,14 @@ Functions documentation
Returns:
square of norm / magnitude
.. c:function:: float glm_vec_norm(vec3 vec)
.. c:function:: float glm_vec3_norm(vec3 vec)
norm (magnitude) of vec3
Parameters:
| *[in]* **vec** vector
.. c:function:: void glm_vec_add(vec3 a, vec3 b, vec3 dest)
.. c:function:: void glm_vec3_add(vec3 a, vec3 b, vec3 dest)
add a vector to b vector store result in dest
@@ -155,7 +160,7 @@ Functions documentation
| *[in]* **b** vector2
| *[out]* **dest** destination vector
.. c:function:: void glm_vec_adds(vec3 a, float s, vec3 dest)
.. c:function:: void glm_vec3_adds(vec3 a, float s, vec3 dest)
add scalar to v vector store result in dest (d = v + vec(s))
@@ -164,7 +169,7 @@ Functions documentation
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec_sub(vec3 v1, vec3 v2, vec3 dest)
.. c:function:: void glm_vec3_sub(vec3 v1, vec3 v2, vec3 dest)
subtract b vector from a vector store result in dest (d = v1 - v2)
@@ -173,7 +178,7 @@ Functions documentation
| *[in]* **b** vector2
| *[out]* **dest** destination vector
.. c:function:: void glm_vec_subs(vec3 v, float s, vec3 dest)
.. c:function:: void glm_vec3_subs(vec3 v, float s, vec3 dest)
subtract scalar from v vector store result in dest (d = v - vec(s))
@@ -182,7 +187,7 @@ Functions documentation
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec_mul(vec3 a, vec3 b, vec3 d)
.. c:function:: void glm_vec3_mul(vec3 a, vec3 b, vec3 d)
multiply two vector (component-wise multiplication)
@@ -191,7 +196,7 @@ Functions documentation
| *[in]* **b** scalar
| *[out]* **d** result = (a[0] * b[0], a[1] * b[1], a[2] * b[2])
.. c:function:: void glm_vec_scale(vec3 v, float s, vec3 dest)
.. c:function:: void glm_vec3_scale(vec3 v, float s, vec3 dest)
multiply/scale vec3 vector with scalar: result = v * s
@@ -201,7 +206,7 @@ Functions documentation
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec_scale_as(vec3 v, float s, vec3 dest)
.. c:function:: void glm_vec3_scale_as(vec3 v, float s, vec3 dest)
make vec3 vector scale as specified: result = unit(v) * s
@@ -210,7 +215,7 @@ Functions documentation
| *[in]* **s** scalar
| *[out]* **dest** destination vector
.. c:function:: void glm_vec_div(vec3 a, vec3 b, vec3 dest)
.. c:function:: void glm_vec3_div(vec3 a, vec3 b, vec3 dest)
div vector with another component-wise division: d = a / b
@@ -219,7 +224,7 @@ Functions documentation
| *[in]* **b** vector 2
| *[out]* **dest** result = (a[0] / b[0], a[1] / b[1], a[2] / b[2])
.. c:function:: void glm_vec_divs(vec3 v, float s, vec3 dest)
.. c:function:: void glm_vec3_divs(vec3 v, float s, vec3 dest)
div vector with scalar: d = v / s
@@ -228,7 +233,7 @@ Functions documentation
| *[in]* **s** scalar
| *[out]* **dest** result = (a[0] / s, a[1] / s, a[2] / s])
.. c:function:: void glm_vec_addadd(vec3 a, vec3 b, vec3 dest)
.. c:function:: void glm_vec3_addadd(vec3 a, vec3 b, vec3 dest)
| add two vectors and add result to sum
| it applies += operator so dest must be initialized
@@ -238,7 +243,7 @@ Functions documentation
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a + b)
.. c:function:: void glm_vec_subadd(vec3 a, vec3 b, vec3 dest)
.. c:function:: void glm_vec3_subadd(vec3 a, vec3 b, vec3 dest)
| sub two vectors and add result to sum
| it applies += operator so dest must be initialized
@@ -248,7 +253,7 @@ Functions documentation
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a - b)
.. c:function:: void glm_vec_muladd(vec3 a, vec3 b, vec3 dest)
.. c:function:: void glm_vec3_muladd(vec3 a, vec3 b, vec3 dest)
| mul two vectors and add result to sum
| it applies += operator so dest must be initialized
@@ -258,7 +263,7 @@ Functions documentation
| *[in]* **b** vector 2
| *[out]* **dest** dest += (a * b)
.. c:function:: void glm_vec_muladds(vec3 a, float s, vec3 dest)
.. c:function:: void glm_vec3_muladds(vec3 a, float s, vec3 dest)
| mul vector with scalar and add result to sum
| it applies += operator so dest must be initialized
@@ -268,29 +273,33 @@ Functions documentation
| *[in]* **s** scalar
| *[out]* **dest** dest += (a * b)
.. c:function:: void glm_vec_flipsign(vec3 v)
.. c:function:: void glm_vec3_flipsign(vec3 v)
flip sign of all vec3 members
**DEPRACATED!**
use :c:func:`glm_vec3_negate`
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec_flipsign_to(vec3 v, vec3 dest)
.. c:function:: void glm_vec3_flipsign_to(vec3 v, vec3 dest)
flip sign of all vec3 members and store result in dest
**DEPRACATED!**
use :c:func:`glm_vec3_negate_to`
Parameters:
| *[in]* **v** vector
| *[out]* **dest** negated vector
.. c:function:: void glm_vec_negate(vec3 v)
.. c:function:: void glm_vec3_negate(vec3 v)
negate vector components
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec_negate_to(vec3 v, vec3 dest)
.. c:function:: void glm_vec3_negate_to(vec3 v, vec3 dest)
negate vector components and store result in dest
@@ -298,14 +307,14 @@ Functions documentation
| *[in]* **v** vector
| *[out]* **dest** negated vector
.. c:function:: void glm_vec_inv(vec3 v)
.. c:function:: void glm_vec3_inv(vec3 v)
make vector as inverse/opposite of itself
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec_inv_to(vec3 v, vec3 dest)
.. c:function:: void glm_vec3_inv_to(vec3 v, vec3 dest)
inverse/opposite vector
@@ -313,14 +322,14 @@ Functions documentation
| *[in]* **v** source
| *[out]* **dest** destination
.. c:function:: void glm_vec_normalize(vec3 v)
.. c:function:: void glm_vec3_normalize(vec3 v)
normalize vec3 and store result in same vec
Parameters:
| *[in, out]* **v** vector
.. c:function:: void glm_vec_normalize_to(vec3 vec, vec3 dest)
.. c:function:: void glm_vec3_normalize_to(vec3 vec, vec3 dest)
normalize vec3 to dest
@@ -328,7 +337,7 @@ Functions documentation
| *[in]* **vec** source
| *[out]* **dest** destination
.. c:function:: float glm_vec_angle(vec3 v1, vec3 v2)
.. c:function:: float glm_vec3_angle(vec3 v1, vec3 v2)
angle betwen two vector
@@ -339,7 +348,7 @@ Functions documentation
Return:
| angle as radians
.. c:function:: void glm_vec_rotate(vec3 v, float angle, vec3 axis)
.. c:function:: void glm_vec3_rotate(vec3 v, float angle, vec3 axis)
rotate vec3 around axis by angle using Rodrigues' rotation formula
@@ -348,7 +357,7 @@ Functions documentation
| *[in]* **axis** axis vector (will be normalized)
| *[out]* **angle** angle (radians)
.. c:function:: void glm_vec_rotate_m4(mat4 m, vec3 v, vec3 dest)
.. c:function:: void glm_vec3_rotate_m4(mat4 m, vec3 v, vec3 dest)
apply rotation matrix to vector
@@ -357,7 +366,7 @@ Functions documentation
| *[in]* **v** vector
| *[out]* **dest** rotated vector
.. c:function:: void glm_vec_rotate_m3(mat3 m, vec3 v, vec3 dest)
.. c:function:: void glm_vec3_rotate_m3(mat3 m, vec3 v, vec3 dest)
apply rotation matrix to vector
@@ -366,7 +375,7 @@ Functions documentation
| *[in]* **v** vector
| *[out]* **dest** rotated vector
.. c:function:: void glm_vec_proj(vec3 a, vec3 b, vec3 dest)
.. c:function:: void glm_vec3_proj(vec3 a, vec3 b, vec3 dest)
project a vector onto b vector
@@ -375,7 +384,7 @@ Functions documentation
| *[in]* **b** vector2
| *[out]* **dest** projected vector
.. c:function:: void glm_vec_center(vec3 v1, vec3 v2, vec3 dest)
.. c:function:: void glm_vec3_center(vec3 v1, vec3 v2, vec3 dest)
find center point of two vector
@@ -384,7 +393,7 @@ Functions documentation
| *[in]* **v2** vector2
| *[out]* **dest** center point
.. c:function:: float glm_vec_distance2(vec3 v1, vec3 v2)
.. c:function:: float glm_vec3_distance2(vec3 v1, vec3 v2)
squared distance between two vectors
@@ -395,7 +404,7 @@ Functions documentation
Returns:
| squared distance (distance * distance)
.. c:function:: float glm_vec_distance(vec3 v1, vec3 v2)
.. c:function:: float glm_vec3_distance(vec3 v1, vec3 v2)
distance between two vectors
@@ -406,7 +415,7 @@ Functions documentation
Returns:
| distance
.. c:function:: void glm_vec_maxv(vec3 v1, vec3 v2, vec3 dest)
.. c:function:: void glm_vec3_maxv(vec3 v1, vec3 v2, vec3 dest)
max values of vectors
@@ -415,7 +424,7 @@ Functions documentation
| *[in]* **v2** vector2
| *[out]* **dest** destination
.. c:function:: void glm_vec_minv(vec3 v1, vec3 v2, vec3 dest)
.. c:function:: void glm_vec3_minv(vec3 v1, vec3 v2, vec3 dest)
min values of vectors
@@ -424,7 +433,7 @@ Functions documentation
| *[in]* **v2** vector2
| *[out]* **dest** destination
.. c:function:: void glm_vec_ortho(vec3 v, vec3 dest)
.. c:function:: void glm_vec3_ortho(vec3 v, vec3 dest)
possible orthogonal/perpendicular vector
@@ -432,7 +441,7 @@ Functions documentation
| *[in]* **mat** vector
| *[out]* **dest** orthogonal/perpendicular vector
.. c:function:: void glm_vec_clamp(vec3 v, float minVal, float maxVal)
.. c:function:: void glm_vec3_clamp(vec3 v, float minVal, float maxVal)
constrain a value to lie between two further values
@@ -441,7 +450,7 @@ Functions documentation
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_vec_lerp(vec3 from, vec3 to, float t, vec3 dest)
.. c:function:: void glm_vec3_lerp(vec3 from, vec3 to, float t, vec3 dest)
linear interpolation between two vector