1
0

reference-libobs-graphics-vec3.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. 3-Component Vector
  2. ==================
  3. .. code:: cpp
  4. #include <graphics/vec3.h>
  5. .. struct:: vec3
  6. Two component vector structure.
  7. .. member:: float vec3.x
  8. X component
  9. .. member:: float vec3.y
  10. Y component
  11. .. member:: float vec3.z
  12. Z component
  13. .. member:: float vec3.ptr[3]
  14. Unioned array of all components
  15. ---------------------
  16. .. function:: void vec3_zero(struct vec3 *dst)
  17. Zeroes a vector
  18. :param dst: Destination
  19. ---------------------
  20. .. function:: void vec3_set(struct vec3 *dst, float x, float y)
  21. Sets the individual components of a 3-component vector.
  22. :param dst: Destination
  23. :param x: X component
  24. :param y: Y component
  25. :param y: Z component
  26. ---------------------
  27. .. function:: void vec3_copy(struct vec3 *dst, const struct vec3 *v)
  28. Copies a vector
  29. :param dst: Destination
  30. :param v: Vector to copy
  31. ---------------------
  32. .. function:: void vec3_from_vec4(struct vec3 *dst, const struct vec4 *v)
  33. Creates a 3-component vector from a 4-component vector
  34. :param dst: 3-component vector destination
  35. :param v: 4-component vector
  36. ---------------------
  37. .. function:: void vec3_add(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
  38. Adds two vectors
  39. :param dst: Destination
  40. :param v1: Vector 1
  41. :param v2: Vector 2
  42. ---------------------
  43. .. function:: void vec3_sub(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
  44. Subtracts two vectors
  45. :param dst: Destination
  46. :param v1: Vector being subtracted from
  47. :param v2: Vector being subtracted
  48. ---------------------
  49. .. function:: void vec3_mul(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
  50. Multiplies two vectors
  51. :param dst: Destination
  52. :param v1: Vector 1
  53. :param v2: Vector 2
  54. ---------------------
  55. .. function:: void vec3_div(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
  56. Divides two vectors
  57. :param dst: Destination
  58. :param v1: Dividend
  59. :param v2: Divisor
  60. ---------------------
  61. .. function:: void vec3_addf(struct vec3 *dst, const struct vec3 *v, float f)
  62. Adds a floating point to all components
  63. :param dst: Destination
  64. :param dst: Vector
  65. :param f: Floating point
  66. ---------------------
  67. .. function:: void vec3_subf(struct vec3 *dst, const struct vec3 *v, float f)
  68. Subtracts a floating point from all components
  69. :param dst: Destination
  70. :param v: Vector being subtracted from
  71. :param f: Floating point being subtracted
  72. ---------------------
  73. .. function:: void vec3_mulf(struct vec3 *dst, const struct vec3 *v, float f)
  74. Multiplies a floating point with all components
  75. :param dst: Destination
  76. :param dst: Vector
  77. :param f: Floating point
  78. ---------------------
  79. .. function:: void vec3_divf(struct vec3 *dst, const struct vec3 *v, float f)
  80. Divides a floating point from all components
  81. :param dst: Destination
  82. :param v: Vector (dividend)
  83. :param f: Floating point (divisor)
  84. ---------------------
  85. .. function:: void vec3_neg(struct vec3 *dst, const struct vec3 *v)
  86. Negates a vector
  87. :param dst: Destination
  88. :param v: Vector to negate
  89. ---------------------
  90. .. function:: float vec3_dot(const struct vec3 *v1, const struct vec3 *v2)
  91. Performs a dot product between two vectors
  92. :param v1: Vector 1
  93. :param v2: Vector 2
  94. :return: Result of the dot product
  95. ---------------------
  96. .. function:: void vec3_cross(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
  97. Performs a cross product between two vectors
  98. :param dst: Destination
  99. :param v1: Vector 1
  100. :param v2: Vector 2
  101. ---------------------
  102. .. function:: float vec3_len(const struct vec3 *v)
  103. Gets the length of a vector
  104. :param v: Vector
  105. :return: The vector's length
  106. ---------------------
  107. .. function:: float vec3_dist(const struct vec3 *v1, const struct vec3 *v2)
  108. Gets the distance between two vectors
  109. :param v1: Vector 1
  110. :param v2: Vector 2
  111. :return: Distance between the two vectors
  112. ---------------------
  113. .. function:: void vec3_minf(struct vec3 *dst, const struct vec3 *v, float val)
  114. Gets the minimum values between a vector's components and a floating point
  115. :param dst: Destination
  116. :param v: Vector
  117. :param val: Floating point
  118. ---------------------
  119. .. function:: void vec3_min(struct vec3 *dst, const struct vec3 *v, const struct vec3 *min_v)
  120. Gets the minimum values between two vectors
  121. :param dst: Destination
  122. :param v: Vector 1
  123. :param min_v: Vector 2
  124. ---------------------
  125. .. function:: void vec3_maxf(struct vec3 *dst, const struct vec3 *v, float val)
  126. Gets the maximum values between a vector's components and a floating point
  127. :param dst: Destination
  128. :param v: Vector
  129. :param val: Floating point
  130. ---------------------
  131. .. function:: void vec3_max(struct vec3 *dst, const struct vec3 *v, const struct vec3 *max_v)
  132. Gets the maximum values between two vectors
  133. :param dst: Destination
  134. :param v: Vector 1
  135. :param max_v: Vector 2
  136. ---------------------
  137. .. function:: void vec3_abs(struct vec3 *dst, const struct vec3 *v)
  138. Gets the absolute values of each component
  139. :param dst: Destination
  140. :param v: Vector
  141. ---------------------
  142. .. function:: void vec3_floor(struct vec3 *dst, const struct vec3 *v)
  143. Gets the floor values of each component
  144. :param dst: Destination
  145. :param v: Vector
  146. ---------------------
  147. .. function:: void vec3_ceil(struct vec3 *dst, const struct vec3 *v)
  148. Gets the ceiling values of each component
  149. :param dst: Destination
  150. :param v: Vector
  151. ---------------------
  152. .. function:: int vec3_close(const struct vec3 *v1, const struct vec3 *v2, float epsilon)
  153. Compares two vectors
  154. :param v1: Vector 1
  155. :param v2: Vector 2
  156. :param epsilon: Maximum precision for comparison
  157. ---------------------
  158. .. function:: void vec3_norm(struct vec3 *dst, const struct vec3 *v)
  159. Normalizes a vector
  160. :param dst: Destination
  161. :param v: Vector to normalize
  162. ---------------------
  163. .. function:: void vec3_transform(struct vec3 *dst, const struct vec3 *v, const struct matrix4 *m)
  164. Transforms a vector
  165. :param dst: Destination
  166. :param v: Vector
  167. :param m: Matrix
  168. ---------------------
  169. .. function:: void vec3_rotate(struct vec3 *dst, const struct vec3 *v, const struct matrix3 *m)
  170. Rotates a vector
  171. :param dst: Destination
  172. :param v: Vector
  173. :param m: Matrix
  174. ---------------------
  175. .. function:: void vec3_rand(struct vec3 *dst, int positive_only)
  176. Generates a random vector
  177. :param dst: Destination
  178. :param positive_only: *true* if positive only, *false* otherwise