reference-libobs-graphics-vec4.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. 4-Component Vector
  2. ==================
  3. .. code:: cpp
  4. #include <graphics/vec4.h>
  5. .. type:: struct vec4
  6. Two component vector structure.
  7. .. member:: float vec4.x
  8. X component
  9. .. member:: float vec4.y
  10. Y component
  11. .. member:: float vec4.z
  12. Z component
  13. .. member:: float vec4.w
  14. W component
  15. .. member:: float vec4.ptr[4]
  16. Unioned array of all components
  17. ---------------------
  18. .. function:: void vec4_zero(struct vec4 *dst)
  19. Zeroes a vector
  20. :param dst: Destination
  21. ---------------------
  22. .. function:: void vec4_set(struct vec4 *dst, float x, float y, float z, float w)
  23. Sets the individual components of a 4-component vector.
  24. :param dst: Destination
  25. :param x: X component
  26. :param y: Y component
  27. :param z: Z component
  28. :param w: W component
  29. ---------------------
  30. .. function:: void vec4_copy(struct vec4 *dst, const struct vec4 *v)
  31. Copies a vector
  32. :param dst: Destination
  33. :param v: Vector to copy
  34. ---------------------
  35. .. function:: void vec4_from_vec3(struct vec4 *dst, const struct vec3 *v)
  36. Creates a 4-component vector from a 3-component vector
  37. :param dst: 4-component vector destination
  38. :param v: 3-component vector
  39. ---------------------
  40. .. function:: void vec4_add(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
  41. Adds two vectors
  42. :param dst: Destination
  43. :param v1: Vector 1
  44. :param v2: Vector 2
  45. ---------------------
  46. .. function:: void vec4_sub(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
  47. Subtracts two vectors
  48. :param dst: Destination
  49. :param v1: Vector being subtracted from
  50. :param v2: Vector being subtracted
  51. ---------------------
  52. .. function:: void vec4_mul(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
  53. Multiplies two vectors
  54. :param dst: Destination
  55. :param v1: Vector 1
  56. :param v2: Vector 2
  57. ---------------------
  58. .. function:: void vec4_div(struct vec4 *dst, const struct vec4 *v1, const struct vec4 *v2)
  59. Divides two vectors
  60. :param dst: Destination
  61. :param v1: Dividend
  62. :param v2: Divisor
  63. ---------------------
  64. .. function:: void vec4_addf(struct vec4 *dst, const struct vec4 *v, float f)
  65. Adds a floating point to all components
  66. :param dst: Destination
  67. :param dst: Vector
  68. :param f: Floating point
  69. ---------------------
  70. .. function:: void vec4_subf(struct vec4 *dst, const struct vec4 *v, float f)
  71. Subtracts a floating point from all components
  72. :param dst: Destination
  73. :param v: Vector being subtracted from
  74. :param f: Floating point being subtracted
  75. ---------------------
  76. .. function:: void vec4_mulf(struct vec4 *dst, const struct vec4 *v, float f)
  77. Multiplies a floating point with all components
  78. :param dst: Destination
  79. :param dst: Vector
  80. :param f: Floating point
  81. ---------------------
  82. .. function:: void vec4_divf(struct vec4 *dst, const struct vec4 *v, float f)
  83. Divides a floating point from all components
  84. :param dst: Destination
  85. :param v: Vector (dividend)
  86. :param f: Floating point (divisor)
  87. ---------------------
  88. .. function:: void vec4_neg(struct vec4 *dst, const struct vec4 *v)
  89. Negates a vector
  90. :param dst: Destination
  91. :param v: Vector to negate
  92. ---------------------
  93. .. function:: float vec4_dot(const struct vec4 *v1, const struct vec4 *v2)
  94. Performs a dot product between two vectors
  95. :param v1: Vector 1
  96. :param v2: Vector 2
  97. :return: Result of the dot product
  98. ---------------------
  99. .. function:: float vec4_len(const struct vec4 *v)
  100. Gets the length of a vector
  101. :param v: Vector
  102. :return: The vector's length
  103. ---------------------
  104. .. function:: float vec4_dist(const struct vec4 *v1, const struct vec4 *v2)
  105. Gets the distance between two vectors
  106. :param v1: Vector 1
  107. :param v2: Vector 2
  108. :return: Distance between the two vectors
  109. ---------------------
  110. .. function:: void vec4_minf(struct vec4 *dst, const struct vec4 *v, float val)
  111. Gets the minimum values between a vector's components and a floating point
  112. :param dst: Destination
  113. :param v: Vector
  114. :param val: Floating point
  115. ---------------------
  116. .. function:: void vec4_min(struct vec4 *dst, const struct vec4 *v, const struct vec4 *min_v)
  117. Gets the minimum values between two vectors
  118. :param dst: Destination
  119. :param v: Vector 1
  120. :param min_v: Vector 2
  121. ---------------------
  122. .. function:: void vec4_maxf(struct vec4 *dst, const struct vec4 *v, float val)
  123. Gets the maximum values between a vector's components and a floating point
  124. :param dst: Destination
  125. :param v: Vector
  126. :param val: Floating point
  127. ---------------------
  128. .. function:: void vec4_max(struct vec4 *dst, const struct vec4 *v, const struct vec4 *max_v)
  129. Gets the maximum values between two vectors
  130. :param dst: Destination
  131. :param v: Vector 1
  132. :param max_v: Vector 2
  133. ---------------------
  134. .. function:: void vec4_abs(struct vec4 *dst, const struct vec4 *v)
  135. Gets the absolute values of each component
  136. :param dst: Destination
  137. :param v: Vector
  138. ---------------------
  139. .. function:: void vec4_floor(struct vec4 *dst, const struct vec4 *v)
  140. Gets the floor values of each component
  141. :param dst: Destination
  142. :param v: Vector
  143. ---------------------
  144. .. function:: void vec4_ceil(struct vec4 *dst, const struct vec4 *v)
  145. Gets the ceiling values of each component
  146. :param dst: Destination
  147. :param v: Vector
  148. ---------------------
  149. .. function:: int vec4_close(const struct vec4 *v1, const struct vec4 *v2, float epsilon)
  150. Compares two vectors
  151. :param v1: Vector 1
  152. :param v2: Vector 2
  153. :param epsilon: Maximum precision for comparison
  154. ---------------------
  155. .. function:: void vec4_norm(struct vec4 *dst, const struct vec4 *v)
  156. Normalizes a vector
  157. :param dst: Desination
  158. :param v: Vector to normalize
  159. ---------------------
  160. .. function:: void vec4_transform(struct vec4 *dst, const struct vec4 *v, const struct matrix4 *m)
  161. Transforms a vector
  162. :param dst: Destination
  163. :param v: Vector
  164. :param m: Matrix