util.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. .. default-domain:: C
  2. utils / helpers
  3. ================================================================================
  4. Header: cglm/util.h
  5. Table of contents (click to go):
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. Functions:
  8. 1. :c:func:`glm_sign`
  9. #. :c:func:`glm_signf`
  10. #. :c:func:`glm_rad`
  11. #. :c:func:`glm_deg`
  12. #. :c:func:`glm_make_rad`
  13. #. :c:func:`glm_make_deg`
  14. #. :c:func:`glm_pow2`
  15. #. :c:func:`glm_min`
  16. #. :c:func:`glm_max`
  17. #. :c:func:`glm_clamp`
  18. #. :c:func:`glm_lerp`
  19. Functions documentation
  20. ~~~~~~~~~~~~~~~~~~~~~~~
  21. .. c:function:: int glm_sign(int val)
  22. | returns sign of 32 bit integer as +1, -1, 0
  23. | **Important**: It returns 0 for zero input
  24. Parameters:
  25. | *[in]* **val** an integer
  26. Returns:
  27. sign of given number
  28. .. c:function:: float glm_signf(float val)
  29. | returns sign of 32 bit integer as +1.0, -1.0, 0.0
  30. | **Important**: It returns 0.0f for zero input
  31. Parameters:
  32. | *[in]* **val** a float
  33. Returns:
  34. sign of given number
  35. .. c:function:: float glm_rad(float deg)
  36. | convert degree to radians
  37. Parameters:
  38. | *[in]* **deg** angle in degrees
  39. .. c:function:: float glm_deg(float rad)
  40. | convert radians to degree
  41. Parameters:
  42. | *[in]* **rad** angle in radians
  43. .. c:function:: void glm_make_rad(float *degm)
  44. | convert exsisting degree to radians. this will override degrees value
  45. Parameters:
  46. | *[in, out]* **deg** pointer to angle in degrees
  47. .. c:function:: void glm_make_deg(float *rad)
  48. | convert exsisting radians to degree. this will override radians value
  49. Parameters:
  50. | *[in, out]* **rad** pointer to angle in radians
  51. .. c:function:: float glm_pow2(float x)
  52. | multiplies given parameter with itself = x * x or powf(x, 2)
  53. Parameters:
  54. | *[in]* **x** value
  55. Returns:
  56. square of a given number
  57. .. c:function:: float glm_min(float a, float b)
  58. | returns minimum of given two values
  59. Parameters:
  60. | *[in]* **a** number 1
  61. | *[in]* **b** number 2
  62. Returns:
  63. minimum value
  64. .. c:function:: float glm_max(float a, float b)
  65. | returns maximum of given two values
  66. Parameters:
  67. | *[in]* **a** number 1
  68. | *[in]* **b** number 2
  69. Returns:
  70. maximum value
  71. .. c:function:: void glm_clamp(float val, float minVal, float maxVal)
  72. constrain a value to lie between two further values
  73. Parameters:
  74. | *[in]* **val** input value
  75. | *[in]* **minVal** minimum value
  76. | *[in]* **maxVal** maximum value
  77. Returns:
  78. clamped value
  79. .. c:function:: float glm_lerp(float from, float to, float t)
  80. linear interpolation between two number
  81. | formula: from + s * (to - from)
  82. Parameters:
  83. | *[in]* **from** from value
  84. | *[in]* **to** to value
  85. | *[in]* **t** interpolant (amount) clamped between 0 and 1
  86. Returns:
  87. interpolated value
  88. .. c:function:: bool glm_eq(float a, float b)
  89. check if two float equal with using EPSILON
  90. Parameters:
  91. | *[in]* **a** a
  92. | *[in]* **b** b
  93. Returns:
  94. true if a and b equals
  95. .. c:function:: float glm_percent(float from, float to, float current)
  96. percentage of current value between start and end value
  97. Parameters:
  98. | *[in]* **from** from value
  99. | *[in]* **to** to value
  100. | *[in]* **current** value between from and to values
  101. Returns:
  102. clamped normalized percent (0-100 in 0-1)
  103. .. c:function:: float glm_percentc(float from, float to, float current)
  104. clamped percentage of current value between start and end value
  105. Parameters:
  106. | *[in]* **from** from value
  107. | *[in]* **to** to value
  108. | *[in]* **current** value between from and to values
  109. Returns:
  110. clamped normalized percent (0-100 in 0-1)