Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

535 lines
27KB

  1. /// @ref core
  2. /// @file glm/common.hpp
  3. ///
  4. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  5. ///
  6. /// @defgroup core_func_common Common functions
  7. /// @ingroup core
  8. ///
  9. /// Include <glm/common.hpp> to use these core features.
  10. ///
  11. /// These all operate component-wise. The description is per component.
  12. #pragma once
  13. #include "detail/setup.hpp"
  14. #include "detail/qualifier.hpp"
  15. #include "detail/type_int.hpp"
  16. #include "detail/_fixes.hpp"
  17. namespace glm
  18. {
  19. /// @addtogroup core_func_common
  20. /// @{
  21. /// Returns x if x >= 0; otherwise, it returns -x.
  22. ///
  23. /// @tparam genType floating-point or signed integer; scalar or vector types.
  24. ///
  25. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
  26. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  27. /// @see qualifier
  28. template<typename genType>
  29. GLM_FUNC_DECL genType abs(genType x);
  30. /// Returns x if x >= 0; otherwise, it returns -x.
  31. ///
  32. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  33. /// @tparam T Floating-point or signed integer scalar types
  34. /// @tparam Q Value from qualifier enum
  35. ///
  36. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
  37. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  38. template<length_t L, typename T, qualifier Q>
  39. GLM_FUNC_DECL vec<L, T, Q> abs(vec<L, T, Q> const& x);
  40. /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
  41. ///
  42. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  43. /// @tparam T Floating-point scalar types
  44. /// @tparam Q Value from qualifier enum
  45. ///
  46. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
  47. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  48. template<length_t L, typename T, qualifier Q>
  49. GLM_FUNC_DECL vec<L, T, Q> sign(vec<L, T, Q> const& x);
  50. /// Returns a value equal to the nearest integer that is less then or equal to x.
  51. ///
  52. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  53. /// @tparam T Floating-point scalar types
  54. /// @tparam Q Value from qualifier enum
  55. ///
  56. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floor.xml">GLSL floor man page</a>
  57. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  58. template<length_t L, typename T, qualifier Q>
  59. GLM_FUNC_DECL vec<L, T, Q> floor(vec<L, T, Q> const& x);
  60. /// Returns a value equal to the nearest integer to x
  61. /// whose absolute value is not larger than the absolute value of x.
  62. ///
  63. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  64. /// @tparam T Floating-point scalar types
  65. /// @tparam Q Value from qualifier enum
  66. ///
  67. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/trunc.xml">GLSL trunc man page</a>
  68. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  69. template<length_t L, typename T, qualifier Q>
  70. GLM_FUNC_DECL vec<L, T, Q> trunc(vec<L, T, Q> const& x);
  71. /// Returns a value equal to the nearest integer to x.
  72. /// The fraction 0.5 will round in a direction chosen by the
  73. /// implementation, presumably the direction that is fastest.
  74. /// This includes the possibility that round(x) returns the
  75. /// same value as roundEven(x) for all values of x.
  76. ///
  77. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  78. /// @tparam T Floating-point scalar types
  79. /// @tparam Q Value from qualifier enum
  80. ///
  81. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
  82. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  83. template<length_t L, typename T, qualifier Q>
  84. GLM_FUNC_DECL vec<L, T, Q> round(vec<L, T, Q> const& x);
  85. /// Returns a value equal to the nearest integer to x.
  86. /// A fractional part of 0.5 will round toward the nearest even
  87. /// integer. (Both 3.5 and 4.5 for x will return 4.0.)
  88. ///
  89. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  90. /// @tparam T Floating-point scalar types
  91. /// @tparam Q Value from qualifier enum
  92. ///
  93. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/roundEven.xml">GLSL roundEven man page</a>
  94. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  95. /// @see <a href="http://developer.amd.com/documentation/articles/pages/New-Round-to-Even-Technique.aspx">New round to even technique</a>
  96. template<length_t L, typename T, qualifier Q>
  97. GLM_FUNC_DECL vec<L, T, Q> roundEven(vec<L, T, Q> const& x);
  98. /// Returns a value equal to the nearest integer
  99. /// that is greater than or equal to x.
  100. ///
  101. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  102. /// @tparam T Floating-point scalar types
  103. /// @tparam Q Value from qualifier enum
  104. ///
  105. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ceil.xml">GLSL ceil man page</a>
  106. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  107. template<length_t L, typename T, qualifier Q>
  108. GLM_FUNC_DECL vec<L, T, Q> ceil(vec<L, T, Q> const& x);
  109. /// Return x - floor(x).
  110. ///
  111. /// @tparam genType Floating-point scalar or vector types.
  112. ///
  113. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract man page</a>
  114. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  115. template<typename genType>
  116. GLM_FUNC_DECL genType fract(genType x);
  117. /// Return x - floor(x).
  118. ///
  119. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  120. /// @tparam T Floating-point scalar types
  121. /// @tparam Q Value from qualifier enum
  122. ///
  123. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract man page</a>
  124. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  125. template<length_t L, typename T, qualifier Q>
  126. GLM_FUNC_DECL vec<L, T, Q> fract(vec<L, T, Q> const& x);
  127. template<typename genType>
  128. GLM_FUNC_DECL genType mod(genType x, genType y);
  129. template<length_t L, typename T, qualifier Q>
  130. GLM_FUNC_DECL vec<L, T, Q> mod(vec<L, T, Q> const& x, T y);
  131. /// Modulus. Returns x - y * floor(x / y)
  132. /// for each component in x using the floating point value y.
  133. ///
  134. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  135. /// @tparam T Floating-point scalar types, include glm/gtc/integer for integer scalar types support
  136. /// @tparam Q Value from qualifier enum
  137. ///
  138. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
  139. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  140. template<length_t L, typename T, qualifier Q>
  141. GLM_FUNC_DECL vec<L, T, Q> mod(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
  142. /// Returns the fractional part of x and sets i to the integer
  143. /// part (as a whole number floating point value). Both the
  144. /// return value and the output parameter will have the same
  145. /// sign as x.
  146. ///
  147. /// @tparam genType Floating-point scalar or vector types.
  148. ///
  149. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml">GLSL modf man page</a>
  150. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  151. template<typename genType>
  152. GLM_FUNC_DECL genType modf(genType x, genType& i);
  153. /// Returns y if y < x; otherwise, it returns x.
  154. ///
  155. /// @tparam genType Floating-point or integer; scalar or vector types.
  156. ///
  157. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
  158. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  159. template<typename genType>
  160. GLM_FUNC_DECL genType min(genType x, genType y);
  161. /// Returns y if y < x; otherwise, it returns x.
  162. ///
  163. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  164. /// @tparam T Floating-point or integer scalar types
  165. /// @tparam Q Value from qualifier enum
  166. ///
  167. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
  168. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  169. template<length_t L, typename T, qualifier Q>
  170. GLM_FUNC_DECL vec<L, T, Q> min(vec<L, T, Q> const& x, T y);
  171. /// Returns y if y < x; otherwise, it returns x.
  172. ///
  173. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  174. /// @tparam T Floating-point or integer scalar types
  175. /// @tparam Q Value from qualifier enum
  176. ///
  177. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
  178. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  179. template<length_t L, typename T, qualifier Q>
  180. GLM_FUNC_DECL vec<L, T, Q> min(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
  181. /// Returns y if x < y; otherwise, it returns x.
  182. ///
  183. /// @tparam genType Floating-point or integer; scalar or vector types.
  184. ///
  185. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
  186. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  187. template<typename genType>
  188. GLM_FUNC_DECL genType max(genType x, genType y);
  189. /// Returns y if x < y; otherwise, it returns x.
  190. ///
  191. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  192. /// @tparam T Floating-point or integer scalar types
  193. /// @tparam Q Value from qualifier enum
  194. ///
  195. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
  196. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  197. template<length_t L, typename T, qualifier Q>
  198. GLM_FUNC_DECL vec<L, T, Q> max(vec<L, T, Q> const& x, T y);
  199. /// Returns y if x < y; otherwise, it returns x.
  200. ///
  201. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  202. /// @tparam T Floating-point or integer scalar types
  203. /// @tparam Q Value from qualifier enum
  204. ///
  205. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
  206. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  207. template<length_t L, typename T, qualifier Q>
  208. GLM_FUNC_DECL vec<L, T, Q> max(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
  209. /// Returns min(max(x, minVal), maxVal) for each component in x
  210. /// using the floating-point values minVal and maxVal.
  211. ///
  212. /// @tparam genType Floating-point or integer; scalar or vector types.
  213. ///
  214. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
  215. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  216. template<typename genType>
  217. GLM_FUNC_DECL genType clamp(genType x, genType minVal, genType maxVal);
  218. /// Returns min(max(x, minVal), maxVal) for each component in x
  219. /// using the floating-point values minVal and maxVal.
  220. ///
  221. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  222. /// @tparam T Floating-point or integer scalar types
  223. /// @tparam Q Value from qualifier enum
  224. ///
  225. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
  226. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  227. template<length_t L, typename T, qualifier Q>
  228. GLM_FUNC_DECL vec<L, T, Q> clamp(vec<L, T, Q> const& x, T minVal, T maxVal);
  229. /// Returns min(max(x, minVal), maxVal) for each component in x
  230. /// using the floating-point values minVal and maxVal.
  231. ///
  232. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  233. /// @tparam T Floating-point or integer scalar types
  234. /// @tparam Q Value from qualifier enum
  235. ///
  236. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
  237. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  238. template<length_t L, typename T, qualifier Q>
  239. GLM_FUNC_DECL vec<L, T, Q> clamp(vec<L, T, Q> const& x, vec<L, T, Q> const& minVal, vec<L, T, Q> const& maxVal);
  240. /// If genTypeU is a floating scalar or vector:
  241. /// Returns x * (1.0 - a) + y * a, i.e., the linear blend of
  242. /// x and y using the floating-point value a.
  243. /// The value for a is not restricted to the range [0, 1].
  244. ///
  245. /// If genTypeU is a boolean scalar or vector:
  246. /// Selects which vector each returned component comes
  247. /// from. For a component of 'a' that is false, the
  248. /// corresponding component of 'x' is returned. For a
  249. /// component of 'a' that is true, the corresponding
  250. /// component of 'y' is returned. Components of 'x' and 'y' that
  251. /// are not selected are allowed to be invalid floating point
  252. /// values and will have no effect on the results. Thus, this
  253. /// provides different functionality than
  254. /// genType mix(genType x, genType y, genType(a))
  255. /// where a is a Boolean vector.
  256. ///
  257. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mix.xml">GLSL mix man page</a>
  258. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  259. ///
  260. /// @param[in] x Value to interpolate.
  261. /// @param[in] y Value to interpolate.
  262. /// @param[in] a Interpolant.
  263. ///
  264. /// @tparam genTypeT Floating point scalar or vector.
  265. /// @tparam genTypeU Floating point or boolean scalar or vector. It can't be a vector if it is the length of genTypeT.
  266. ///
  267. /// @code
  268. /// #include <glm/glm.hpp>
  269. /// ...
  270. /// float a;
  271. /// bool b;
  272. /// glm::dvec3 e;
  273. /// glm::dvec3 f;
  274. /// glm::vec4 g;
  275. /// glm::vec4 h;
  276. /// ...
  277. /// glm::vec4 r = glm::mix(g, h, a); // Interpolate with a floating-point scalar two vectors.
  278. /// glm::vec4 s = glm::mix(g, h, b); // Returns g or h;
  279. /// glm::dvec3 t = glm::mix(e, f, a); // Types of the third parameter is not required to match with the first and the second.
  280. /// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter.
  281. /// @endcode
  282. template<typename genTypeT, typename genTypeU>
  283. GLM_FUNC_DECL genTypeT mix(genTypeT x, genTypeT y, genTypeU a);
  284. template<length_t L, typename T, typename U, qualifier Q>
  285. GLM_FUNC_DECL vec<L, T, Q> mix(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, U, Q> const& a);
  286. template<length_t L, typename T, typename U, qualifier Q>
  287. GLM_FUNC_DECL vec<L, T, Q> mix(vec<L, T, Q> const& x, vec<L, T, Q> const& y, U a);
  288. /// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
  289. ///
  290. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
  291. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  292. template<typename genType>
  293. GLM_FUNC_DECL genType step(genType edge, genType x);
  294. /// Returns 0.0 if x < edge, otherwise it returns 1.0.
  295. ///
  296. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  297. /// @tparam T Floating-point scalar types
  298. /// @tparam Q Value from qualifier enum
  299. ///
  300. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
  301. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  302. template<length_t L, typename T, qualifier Q>
  303. GLM_FUNC_DECL vec<L, T, Q> step(T edge, vec<L, T, Q> const& x);
  304. /// Returns 0.0 if x < edge, otherwise it returns 1.0.
  305. ///
  306. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  307. /// @tparam T Floating-point scalar types
  308. /// @tparam Q Value from qualifier enum
  309. ///
  310. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
  311. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  312. template<length_t L, typename T, qualifier Q>
  313. GLM_FUNC_DECL vec<L, T, Q> step(vec<L, T, Q> const& edge, vec<L, T, Q> const& x);
  314. /// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and
  315. /// performs smooth Hermite interpolation between 0 and 1
  316. /// when edge0 < x < edge1. This is useful in cases where
  317. /// you would want a threshold function with a smooth
  318. /// transition. This is equivalent to:
  319. /// genType t;
  320. /// t = clamp ((x - edge0) / (edge1 - edge0), 0, 1);
  321. /// return t * t * (3 - 2 * t);
  322. /// Results are undefined if edge0 >= edge1.
  323. ///
  324. /// @tparam genType Floating-point scalar or vector types.
  325. ///
  326. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/smoothstep.xml">GLSL smoothstep man page</a>
  327. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  328. template<typename genType>
  329. GLM_FUNC_DECL genType smoothstep(genType edge0, genType edge1, genType x);
  330. template<length_t L, typename T, qualifier Q>
  331. GLM_FUNC_DECL vec<L, T, Q> smoothstep(T edge0, T edge1, vec<L, T, Q> const& x);
  332. template<length_t L, typename T, qualifier Q>
  333. GLM_FUNC_DECL vec<L, T, Q> smoothstep(vec<L, T, Q> const& edge0, vec<L, T, Q> const& edge1, vec<L, T, Q> const& x);
  334. /// Returns true if x holds a NaN (not a number)
  335. /// representation in the underlying implementation's set of
  336. /// floating point representations. Returns false otherwise,
  337. /// including for implementations with no NaN
  338. /// representations.
  339. ///
  340. /// /!\ When using compiler fast math, this function may fail.
  341. ///
  342. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  343. /// @tparam T Floating-point scalar types
  344. /// @tparam Q Value from qualifier enum
  345. ///
  346. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isnan.xml">GLSL isnan man page</a>
  347. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  348. template<length_t L, typename T, qualifier Q>
  349. GLM_FUNC_DECL vec<L, bool, Q> isnan(vec<L, T, Q> const& x);
  350. /// Returns true if x holds a positive infinity or negative
  351. /// infinity representation in the underlying implementation's
  352. /// set of floating point representations. Returns false
  353. /// otherwise, including for implementations with no infinity
  354. /// representations.
  355. ///
  356. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  357. /// @tparam T Floating-point scalar types
  358. /// @tparam Q Value from qualifier enum
  359. ///
  360. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isinf.xml">GLSL isinf man page</a>
  361. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  362. template<length_t L, typename T, qualifier Q>
  363. GLM_FUNC_DECL vec<L, bool, Q> isinf(vec<L, T, Q> const& x);
  364. /// Returns a signed integer value representing
  365. /// the encoding of a floating-point value. The floating-point
  366. /// value's bit-level representation is preserved.
  367. ///
  368. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
  369. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  370. GLM_FUNC_DECL int floatBitsToInt(float const& v);
  371. /// Returns a signed integer value representing
  372. /// the encoding of a floating-point value. The floatingpoint
  373. /// value's bit-level representation is preserved.
  374. ///
  375. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  376. /// @tparam Q Value from qualifier enum
  377. ///
  378. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
  379. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  380. template<length_t L, qualifier Q>
  381. GLM_FUNC_DECL vec<L, int, Q> floatBitsToInt(vec<L, float, Q> const& v);
  382. /// Returns a unsigned integer value representing
  383. /// the encoding of a floating-point value. The floatingpoint
  384. /// value's bit-level representation is preserved.
  385. ///
  386. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
  387. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  388. GLM_FUNC_DECL uint floatBitsToUint(float const& v);
  389. /// Returns a unsigned integer value representing
  390. /// the encoding of a floating-point value. The floatingpoint
  391. /// value's bit-level representation is preserved.
  392. ///
  393. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  394. /// @tparam Q Value from qualifier enum
  395. ///
  396. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
  397. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  398. template<length_t L, qualifier Q>
  399. GLM_FUNC_DECL vec<L, uint, Q> floatBitsToUint(vec<L, float, Q> const& v);
  400. /// Returns a floating-point value corresponding to a signed
  401. /// integer encoding of a floating-point value.
  402. /// If an inf or NaN is passed in, it will not signal, and the
  403. /// resulting floating point value is unspecified. Otherwise,
  404. /// the bit-level representation is preserved.
  405. ///
  406. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
  407. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  408. GLM_FUNC_DECL float intBitsToFloat(int const& v);
  409. /// Returns a floating-point value corresponding to a signed
  410. /// integer encoding of a floating-point value.
  411. /// If an inf or NaN is passed in, it will not signal, and the
  412. /// resulting floating point value is unspecified. Otherwise,
  413. /// the bit-level representation is preserved.
  414. ///
  415. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  416. /// @tparam Q Value from qualifier enum
  417. ///
  418. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
  419. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  420. template<length_t L, qualifier Q>
  421. GLM_FUNC_DECL vec<L, float, Q> intBitsToFloat(vec<L, int, Q> const& v);
  422. /// Returns a floating-point value corresponding to a
  423. /// unsigned integer encoding of a floating-point value.
  424. /// If an inf or NaN is passed in, it will not signal, and the
  425. /// resulting floating point value is unspecified. Otherwise,
  426. /// the bit-level representation is preserved.
  427. ///
  428. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
  429. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  430. GLM_FUNC_DECL float uintBitsToFloat(uint const& v);
  431. /// Returns a floating-point value corresponding to a
  432. /// unsigned integer encoding of a floating-point value.
  433. /// If an inf or NaN is passed in, it will not signal, and the
  434. /// resulting floating point value is unspecified. Otherwise,
  435. /// the bit-level representation is preserved.
  436. ///
  437. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  438. /// @tparam Q Value from qualifier enum
  439. ///
  440. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
  441. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  442. template<length_t L, qualifier Q>
  443. GLM_FUNC_DECL vec<L, float, Q> uintBitsToFloat(vec<L, uint, Q> const& v);
  444. /// Computes and returns a * b + c.
  445. ///
  446. /// @tparam genType Floating-point scalar or vector types.
  447. ///
  448. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fma.xml">GLSL fma man page</a>
  449. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  450. template<typename genType>
  451. GLM_FUNC_DECL genType fma(genType const& a, genType const& b, genType const& c);
  452. /// Splits x into a floating-point significand in the range
  453. /// [0.5, 1.0) and an integral exponent of two, such that:
  454. /// x = significand * exp(2, exponent)
  455. ///
  456. /// The significand is returned by the function and the
  457. /// exponent is returned in the parameter exp. For a
  458. /// floating-point value of zero, the significant and exponent
  459. /// are both zero. For a floating-point value that is an
  460. /// infinity or is not a number, the results are undefined.
  461. ///
  462. /// @tparam genType Floating-point scalar or vector types.
  463. ///
  464. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
  465. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  466. template<typename genType, typename genIType>
  467. GLM_FUNC_DECL genType frexp(genType const& x, genIType& exp);
  468. /// Builds a floating-point number from x and the
  469. /// corresponding integral exponent of two in exp, returning:
  470. /// significand * exp(2, exponent)
  471. ///
  472. /// If this product is too large to be represented in the
  473. /// floating-point type, the result is undefined.
  474. ///
  475. /// @tparam genType Floating-point scalar or vector types.
  476. ///
  477. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
  478. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
  479. template<typename genType, typename genIType>
  480. GLM_FUNC_DECL genType ldexp(genType const& x, genIType const& exp);
  481. /// @}
  482. }//namespace glm
  483. #include "detail/func_common.inl"