vec4.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. .. default-domain:: C
  2. vec4
  3. ====
  4. Header: cglm/vec4.h
  5. Table of contents (click to go):
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. Macros:
  8. 1. glm_vec4_dup3(v, dest)
  9. #. glm_vec4_dup(v, dest)
  10. #. GLM_VEC4_ONE_INIT
  11. #. GLM_VEC4_BLACK_INIT
  12. #. GLM_VEC4_ZERO_INIT
  13. #. GLM_VEC4_ONE
  14. #. GLM_VEC4_BLACK
  15. #. GLM_VEC4_ZERO
  16. Functions:
  17. 1. :c:func:`glm_vec4`
  18. #. :c:func:`glm_vec4_copy3`
  19. #. :c:func:`glm_vec4_copy`
  20. #. :c:func:`glm_vec4_dot`
  21. #. :c:func:`glm_vec4_norm2`
  22. #. :c:func:`glm_vec4_norm`
  23. #. :c:func:`glm_vec4_add`
  24. #. :c:func:`glm_vec4_sub`
  25. #. :c:func:`glm_vec4_scale`
  26. #. :c:func:`glm_vec4_scale_as`
  27. #. :c:func:`glm_vec4_flipsign`
  28. #. :c:func:`glm_vec4_inv`
  29. #. :c:func:`glm_vec4_inv_to`
  30. #. :c:func:`glm_vec4_normalize`
  31. #. :c:func:`glm_vec4_normalize_to`
  32. #. :c:func:`glm_vec4_distance`
  33. #. :c:func:`glm_vec4_maxv`
  34. #. :c:func:`glm_vec4_minv`
  35. Functions documentation
  36. ~~~~~~~~~~~~~~~~~~~~~~~
  37. .. c:function:: void glm_vec4(vec3 v3, float last, vec4 dest)
  38. init vec4 using vec3, since you are initializing vec4 with vec3
  39. you need to set last item. cglm could set it zero but making it parameter
  40. gives more control
  41. Parameters:
  42. | *[in]* **v3** vector4
  43. | *[in]* **last** last item of vec4
  44. | *[out]* **dest** destination
  45. .. c:function:: void glm_vec4_copy3(vec4 a, vec3 dest)
  46. copy first 3 members of [a] to [dest]
  47. Parameters:
  48. | *[in]* **a** source
  49. | *[out]* **dest** destination
  50. .. c:function:: void glm_vec4_copy(vec4 v, vec4 dest)
  51. copy all members of [a] to [dest]
  52. Parameters:
  53. | *[in]* **v** source
  54. | *[in]* **dest** destination
  55. .. c:function:: float glm_vec4_dot(vec4 a, vec4 b)
  56. dot product of vec4
  57. Parameters:
  58. | *[in]* **a** vector1
  59. | *[in]* **b** vector2
  60. Returns:
  61. dot product
  62. .. c:function:: float glm_vec4_norm2(vec4 v)
  63. norm * norm (magnitude) of vector
  64. we can use this func instead of calling norm * norm, because it would call
  65. sqrtf fuction twice but with this func we can avoid func call, maybe this is
  66. not good name for this func
  67. Parameters:
  68. | *[in]* **v** vector
  69. Returns:
  70. square of norm / magnitude
  71. .. c:function:: float glm_vec4_norm(vec4 vec)
  72. norm (magnitude) of vec4
  73. Parameters:
  74. | *[in]* **vec** vector
  75. .. c:function:: void glm_vec4_add(vec4 v1, vec4 v2, vec4 dest)
  76. add v2 vector to v1 vector store result in dest
  77. Parameters:
  78. | *[in]* **v1** vector1
  79. | *[in]* **v2** vector2
  80. | *[out]* **dest** destination vector
  81. .. c:function:: void glm_vec4_sub(vec4 v1, vec4 v2, vec4 dest)
  82. subtract v2 vector from v1 vector store result in dest
  83. Parameters:
  84. | *[in]* **v1** vector1
  85. | *[in]* **v2** vector2
  86. | *[out]* **dest** destination vector
  87. .. c:function:: void glm_vec4_scale(vec4 v, float s, vec4 dest)
  88. multiply/scale vec4 vector with scalar: result = v * s
  89. Parameters:
  90. | *[in]* **v** vector
  91. | *[in]* **s** scalar
  92. | *[out]* **dest** destination vector
  93. .. c:function:: void glm_vec4_scale_as(vec4 v, float s, vec4 dest)
  94. make vec4 vector scale as specified: result = unit(v) * s
  95. Parameters:
  96. | *[in]* **v** vector
  97. | *[in]* **s** scalar
  98. | *[out]* **dest** destination vector
  99. .. c:function:: void glm_vec4_flipsign(vec4 v)
  100. flip sign of all vec4 members
  101. Parameters:
  102. | *[in, out]* **v** vector
  103. .. c:function:: void glm_vec4_inv(vec4 v)
  104. make vector as inverse/opposite of itself
  105. Parameters:
  106. | *[in, out]* **v** vector
  107. .. c:function:: void glm_vec4_inv_to(vec4 v, vec4 dest)
  108. inverse/opposite vector
  109. Parameters:
  110. | *[in]* **v** source
  111. | *[out]* **dest** destination
  112. .. c:function:: void glm_vec4_normalize(vec4 v)
  113. normalize vec4 and store result in same vec
  114. Parameters:
  115. | *[in, out]* **v** vector
  116. .. c:function:: void glm_vec4_normalize_to(vec4 vec, vec4 dest)
  117. normalize vec4 to dest
  118. Parameters:
  119. | *[in]* **vec** source
  120. | *[out]* **dest** destination
  121. .. c:function:: float glm_vec4_distance(vec4 v1, vec4 v2)
  122. distance between two vectors
  123. Parameters:
  124. | *[in]* **mat** vector1
  125. | *[in]* **row1** vector2
  126. Returns:
  127. | distance
  128. .. c:function:: void glm_vec4_maxv(vec4 v1, vec4 v2, vec4 dest)
  129. max values of vectors
  130. Parameters:
  131. | *[in]* **v1** vector1
  132. | *[in]* **v2** vector2
  133. | *[out]* **dest** destination
  134. .. c:function:: void glm_vec4_minv(vec4 v1, vec4 v2, vec4 dest)
  135. min values of vectors
  136. Parameters:
  137. | *[in]* **v1** vector1
  138. | *[in]* **v2** vector2
  139. | *[out]* **dest** destination