reference-libobs-graphics-vec2.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. 2-Component Vector
  2. ==================
  3. .. code:: cpp
  4. #include <graphics/vec2.h>
  5. .. type:: struct vec2
  6. Two component vector structure.
  7. .. member:: float vec2.x
  8. X component
  9. .. member:: float vec2.y
  10. Y component
  11. .. member:: float vec2.ptr[2]
  12. Unioned array of both components
  13. ---------------------
  14. .. function:: void vec2_zero(struct vec2 *dst)
  15. Zeroes a vector
  16. :param dst: Destination
  17. ---------------------
  18. .. function:: void vec2_set(struct vec2 *dst, float x, float y)
  19. Sets the individual components of a 2-component vector.
  20. :param dst: Destination
  21. :param x: X component
  22. :param y: Y component
  23. ---------------------
  24. .. function:: void vec2_copy(struct vec2 *dst, const struct vec2 *v)
  25. Copies a vector
  26. :param dst: Destination
  27. :param v: Vector to copy
  28. ---------------------
  29. .. function:: void vec2_add(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
  30. Adds two vectors
  31. :param dst: Destination
  32. :param v1: Vector 1
  33. :param v2: Vector 2
  34. ---------------------
  35. .. function:: void vec2_sub(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
  36. Subtracts two vectors
  37. :param dst: Destination
  38. :param v1: Vector being subtracted from
  39. :param v2: Vector being subtracted
  40. ---------------------
  41. .. function:: void vec2_mul(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
  42. Multiplies two vectors
  43. :param dst: Destination
  44. :param v1: Vector 1
  45. :param v2: Vector 2
  46. ---------------------
  47. .. function:: void vec2_div(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
  48. Divides two vectors
  49. :param dst: Destination
  50. :param v1: Dividend
  51. :param v2: Divisor
  52. ---------------------
  53. .. function:: void vec2_addf(struct vec2 *dst, const struct vec2 *v, float f)
  54. Adds a floating point to all components
  55. :param dst: Destination
  56. :param dst: Vector
  57. :param f: Floating point
  58. ---------------------
  59. .. function:: void vec2_subf(struct vec2 *dst, const struct vec2 *v, float f)
  60. Subtracts a floating point from all components
  61. :param dst: Destination
  62. :param v: Vector being subtracted from
  63. :param f: Floating point being subtracted
  64. ---------------------
  65. .. function:: void vec2_mulf(struct vec2 *dst, const struct vec2 *v, float f)
  66. Multiplies a floating point with all components
  67. :param dst: Destination
  68. :param dst: Vector
  69. :param f: Floating point
  70. ---------------------
  71. .. function:: void vec2_divf(struct vec2 *dst, const struct vec2 *v, float f)
  72. Divides a floating point from all components
  73. :param dst: Destination
  74. :param v: Vector (dividend)
  75. :param f: Floating point (divisor)
  76. ---------------------
  77. .. function:: void vec2_neg(struct vec2 *dst, const struct vec2 *v)
  78. Negates a vector
  79. :param dst: Destination
  80. :param v: Vector to negate
  81. ---------------------
  82. .. function:: float vec2_dot(const struct vec2 *v1, const struct vec2 *v2)
  83. Performs a dot product between two vectors
  84. :param v1: Vector 1
  85. :param v2: Vector 2
  86. :return: Result of the dot product
  87. ---------------------
  88. .. function:: float vec2_len(const struct vec2 *v)
  89. Gets the length of a vector
  90. :param v: Vector
  91. :return: The vector's length
  92. ---------------------
  93. .. function:: float vec2_dist(const struct vec2 *v1, const struct vec2 *v2)
  94. Gets the distance between two vectors
  95. :param v1: Vector 1
  96. :param v2: Vector 2
  97. :return: Distance between the two vectors
  98. ---------------------
  99. .. function:: void vec2_minf(struct vec2 *dst, const struct vec2 *v, float val)
  100. Gets the minimum values between a vector's components and a floating point
  101. :param dst: Destination
  102. :param v: Vector
  103. :param val: Floating point
  104. ---------------------
  105. .. function:: void vec2_min(struct vec2 *dst, const struct vec2 *v, const struct vec2 *min_v)
  106. Gets the minimum values between two vectors
  107. :param dst: Destination
  108. :param v: Vector 1
  109. :param min_v: Vector 2
  110. ---------------------
  111. .. function:: void vec2_maxf(struct vec2 *dst, const struct vec2 *v, float val)
  112. Gets the maximum values between a vector's components and a floating point
  113. :param dst: Destination
  114. :param v: Vector
  115. :param val: Floating point
  116. ---------------------
  117. .. function:: void vec2_max(struct vec2 *dst, const struct vec2 *v, const struct vec2 *max_v)
  118. Gets the maximum values between two vectors
  119. :param dst: Destination
  120. :param v: Vector 1
  121. :param max_v: Vector 2
  122. ---------------------
  123. .. function:: void vec2_abs(struct vec2 *dst, const struct vec2 *v)
  124. Gets the absolute values of each component
  125. :param dst: Destination
  126. :param v: Vector
  127. ---------------------
  128. .. function:: void vec2_floor(struct vec2 *dst, const struct vec2 *v)
  129. Gets the floor values of each component
  130. :param dst: Destination
  131. :param v: Vector
  132. ---------------------
  133. .. function:: void vec2_ceil(struct vec2 *dst, const struct vec2 *v)
  134. Gets the ceiling values of each component
  135. :param dst: Destination
  136. :param v: Vector
  137. ---------------------
  138. .. function:: int vec2_close(const struct vec2 *v1, const struct vec2 *v2, float epsilon)
  139. Compares two vectors
  140. :param v1: Vector 1
  141. :param v2: Vector 2
  142. :param epsilon: Maximum precision for comparison
  143. ---------------------
  144. .. function:: void vec2_norm(struct vec2 *dst, const struct vec2 *v)
  145. Normalizes a vector
  146. :param dst: Destination
  147. :param v: Vector to normalize